AndHow Home •
User Guide •
User forum •
Live-code Demo
New Release: 1.5.0, October 10, 2022 - notes.
This release jumps from 0.4.2 to 1.5.0, reflecting that AndHow has been in production long enough to be considered production ready, and includes some API changes. This release removes deprecated methods, clarifies / subtly changes some behavior, and has general improvements and bug fixes. See the full [release notes](https://github.com/eeverman/andhow/releases/tag/andhow-1.5.0).
AndHow configures your application with strongly typed Properties that work just like static final
constants in your code. Values for Properties are loaded from multiple sources and are validated
at startup.
- Strong Typing
- Detailed validation
- Simple to use and test
- Use Java
public
&private
modifiers to control Property value access - Validates all property values at startup to Fail Fast
- Loads values from multiple sources (env. vars, system props, cmd line, prop files, JNDI, and more)
- Generates configuration template files for the Properties in your application
<dependency>
<groupId>org.yarnandtail</groupId>
<artifactId>andhow</artifactId>
<version>1.5.0</version>
</dependency>
Declaring Properties looks like this:
private static final StrProp HOST = StrProp.builder().startsWith("internal.").build();
public static final IntProp PORT = IntProp.builder().defaultValue(80).build();
Using Properties looks like this:
String theHost = HOST.getValue();
int thePort = PORT.getValue();
StrProp
& IntProp
are AndHow Property
s.
Properties and their values are constants, so they are always declared as static final
,
but may be private
or any scope. Properties may have default values, validation rules,
description, and more.
Properties are used just like static final constants with .getValue()
tacked on.
They are strongly typed, so HOST.getValue()
returns a String
, PORT.getValue()
returns an Integer
.
At startup, AndHow scans System.Properties
, environment variables, JNDI values,
the andhow.properties
file, etc., in a
well established order.
If the loaded value for any Property in the application does not meet the validation requirements,
AndHow throws a detailed RuntimeException
to fail fast
and prevent the application from running with invalid configuration.
&?! AndHow Home • User Guide • User forum • Live-code Demo &?!