https://github.com/payneteasy/startup-parameters
Parse startup parameters from environment variables and system options
https://github.com/payneteasy/startup-parameters
Last synced: 8 months ago
JSON representation
Parse startup parameters from environment variables and system options
- Host: GitHub
- URL: https://github.com/payneteasy/startup-parameters
- Owner: payneteasy
- License: apache-2.0
- Created: 2019-05-11T15:42:10.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-03-02T18:30:33.000Z (over 4 years ago)
- Last Synced: 2024-12-28T15:38:21.238Z (over 1 year ago)
- Language: Java
- Size: 108 KB
- Stars: 1
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://circleci.com/gh/payneteasy/startup-parameters)
[](https://sonarcloud.io/dashboard?id=com.payneteasy%3Astartup-parameters)
Parse startup parameters
==========================
## Features
* supported types: int, String, File, boolean, char, long, Period, Duration, enums, BigDecimal
* thread safe
## Setup with dependency managers
### Maven
```xml
pne
payneteasy repo
https://maven.pne.io
com.payneteasy
startup-parameters
1.0-10
```
### Gradle
```groovy
compile 'com.payneteasy:startup-parameters:1.0-10'
```
How to use
------------
❶ Create an interface with parameters, [see example](https://github.com/payneteasy/startup-parameters/blob/e2464aa9d9cb9472c0a9cf44717e8bbcaa11801d/src/test/java/com/payneteasy/startup/parameters/IStartupConfig.java#L5)
```java
public interface IStartupConfig {
@AStartupParameter(name = "WEB_SERVER_PORT", value = "8083")
int webServerPort();
@AStartupParameter(name = "WEB_SERVER_CONTEXT", value = "/api")
String webServerContext();
@AStartupParameter(name = "REQUEST_LOG_DIR", value = "./logs")
File getRequestLogDir();
}
```
❷ Create an instance, [see example](https://github.com/payneteasy/startup-parameters/blob/e2464aa9d9cb9472c0a9cf44717e8bbcaa11801d/src/test/java/com/payneteasy/startup/parameters/StartupParametersFactoryTest.java#L13)
```java
IStartupConfig startupConfig = StartupParametersFactory.getStartupParameters(IStartupConfig.class);
int port = startupConfig.webServerPort();
```
Pretty log
----------
```java
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
```
## License
The Startup Parameters library is licensed under the Apache License 2.0