You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: md/config.md
+19-20Lines changed: 19 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,31 +14,31 @@ Any property can be injected using the ```javax.inject.Named``` annotation and a
14
14
15
15
2) Is an enum
16
16
17
-
1) Has a public **constructor** that accepts a single **String** argument
17
+
3) Has a public **constructor** that accepts a single **String** argument
18
18
19
-
2) Has a static method **valueOf** that accepts a single **String** argument
19
+
4) Has a static method **valueOf** that accepts a single **String** argument
20
20
21
-
3) Has a static method **fromString** that accepts a single **String** argument. Like ```java.util.UUID```
21
+
5) Has a static method **fromString** that accepts a single **String** argument. Like ```java.util.UUID```
22
22
23
-
4) Has a static method **forName** that accepts a single **String** argument. Like ```java.nio.charset.Charset```
23
+
6) Has a static method **forName** that accepts a single **String** argument. Like ```java.nio.charset.Charset```
24
24
25
-
5) There is custom Guice type converter for the type
25
+
7) There is custom Guice type converter for the type
26
26
27
-
It is also possible to inject a ```com.typesafe.config.Config``` object.
27
+
It is also possible to inject the root ```com.typesafe.config.Config``` object or a child of it.
28
28
29
29
## special properties
30
30
31
-
### application.mode
31
+
### application.env
32
32
33
-
Jooby internals and the module system rely on the ```application.mode``` property. By defaults, this property is set to ```dev```.
33
+
Jooby internals and the module system rely on the ```application.env``` property. By defaults, this property is set to ```dev```.
34
34
35
-
For example, the [development stage](https://github.com/google/guice/wiki/Bootstrap) is set in [Guice](https://github.com/google/guice) when ```application.mode == dev```. A module provider, might decided to create a connection pool, cache, etc when ```application.mode != dev ```.
35
+
For example, the [development stage](https://github.com/google/guice/wiki/Bootstrap) is set in [Guice](https://github.com/google/guice) when ```application.env == dev```. A module provider, might decided to create a connection pool, cache, etc when ```application.env != dev ```.
36
36
37
-
This special property is represented at runtime with the [Mode]({{apidocs}}/org/jooby/Mode.html) class.
37
+
This special property is represented at runtime with the [Env]({{apidocs}}/org/jooby/Env.html) class.
38
38
39
39
### application.secret
40
40
41
-
The session cookie is signed with an```application.secret```, while you are in **dev** you aren't required to provide an ```application.secret```. A secret is required when environment isn't **dev** and if you fail to provide a secret your application wont startup.
41
+
If present, the session cookie will be signed with the```application.secret```.
42
42
43
43
### default properties
44
44
@@ -67,7 +67,7 @@ It does, but at the same time it is very intuitive and makes a lot of sense. Let
67
67
68
68
### system properties
69
69
70
-
System properties can override any other property. A sys property is be set at startup time, like:
70
+
System properties can override any other property. A sys property is set at startup time, like:
71
71
72
72
java -jar myapp.jar -Dapplication.secret=xyz
73
73
@@ -83,31 +83,31 @@ Let's say your app includes a default property file: ```application.conf``` bund
83
83
* inside that directory create a file: ```application.conf```
84
84
* start the app from same directory
85
85
86
-
That's all. The file system conf file will take precedence over the classpath path config files overriding any property.
86
+
That's all. The file system conf file will take precedence over the classpath config file, overriding any property.
87
87
88
-
A good practice is to start up your app with a **mode**, like:
88
+
A good practice is to start up your app with a **env**, like:
89
89
90
-
java -jar myapp.jar -Dapplication.mode=prod
90
+
java -jar myapp.jar -Dapplication.env=prod
91
91
92
92
The process is the same, except this time you can name your file as:
93
93
94
94
application.prod.conf
95
95
96
96
### cp://[application].[mode].[conf]
97
97
98
-
Again, the use of this conf file is optional and works like previous config option, except that here the **fat jar** was bundled with all your config files (dev, stage, prod, etc.)
98
+
Again, the use of this conf file is optional and works like previous config option, except here the **fat jar** was bundled with all your config files (dev, stage, prod, etc.)
99
99
100
-
Example: you have two config files: ```application.conf``` and ```application.prod.conf````. Both files were bundled with the **fat jar**, starting the app in **prod**mode is:
100
+
Example: you have two config files: ```application.conf``` and ```application.prod.conf````. Both files were bundled inside the **fat jar**, starting the app in **prod**env:
101
101
102
-
java -jar myapp.jar -Dapplication.mode=prod
102
+
java -jar myapp.jar -Dapplication.env=prod
103
103
104
104
So here the ```application.prod.conf``` will takes precedence over the ```application.conf``` conf file.
105
105
106
106
This is the recommended option from Jooby, because your app doesn't have an external dependency. If you need to deploy the app in a new server all you need is your **fat jar**
107
107
108
108
### [application].[conf]
109
109
110
-
This is your default config files and it should be bundle inside the **fat jar**. As mentioned early, the default name is: **application.conf**, but if you don't like it or need to change it just call **use** in Jooby:
110
+
This is the default config files and it should be bundle inside the **fat jar**. As mentioned early, the default name is: **application.conf**, but if you don't like it or need to change it:
111
111
112
112
```java
113
113
{
@@ -130,4 +130,3 @@ As mentioned in the [modules](#modules) section a module might define his own se
130
130
In the previous example the M2 modules properties will take precedence over M1 properties.
131
131
132
132
As you can see the config system is very powerful and can do a lot for you.
0 commit comments