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
Since Micronaut framework 2.3 a banner is shown when the application starts. It is enabled by default, and it also shows the Micronaut version.
2
+
3
+
[source,shell,subs="attributes"]
4
+
----
5
+
$ ./gradlew run
6
+
__ __ _ _
7
+
| \/ (_) ___ _ __ ___ _ __ __ _ _ _| |_
8
+
| |\/| | |/ __| '__/ _ \| '_ \ / _` | | | | __|
9
+
| | | | | (__| | | (_) | | | | (_| | |_| | |_
10
+
|_| |_|_|\___|_| \___/|_| |_|\__,_|\__,_|\__|
11
+
Micronaut ({version})
12
+
13
+
17:07:22.997 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 611ms. Server Running: http://localhost:8080
14
+
----
15
+
16
+
To customize the banner with your own ASCII Art (just plain ASCII at this moment), create the file `src/main/resources/micronaut-banner.txt` and it will be used instead.
The above activates environments called `foo` and `bar`.
18
18
19
19
It is also possible to enable the detection of the Cloud environment the application is deployed to (this feature is disabled by default since Micronaut framework 4). See the section on <<cloudConfiguration,Cloud Configuration>> for more information.
20
-
21
-
== Environment Priority
22
-
23
-
The Micronaut framework loads property sources based on the environments specified, and if the same property key exists in multiple property sources specific to an environment, the environment order determines which value to use.
24
-
25
-
The Micronaut framework uses the following hierarchy for environment processing (lowest to highest priority):
26
-
27
-
* Deduced environments
28
-
* Environments from the `micronaut.environments` system property
29
-
* Environments from the `MICRONAUT_ENVIRONMENTS` environment variable
30
-
* Environments specified explicitly through the application context builder
31
-
+
32
-
NOTE: This also applies to `@MicronautTest(environments = ...)`
33
-
+
34
-
35
-
36
-
== Disabling Environment Detection
37
-
38
-
Automatic detection of environments can be disabled by setting the `micronaut.env.deduction` system property or the `MICRONAUT_ENV_DEDUCTION` environment variable to `false`. This prevents the Micronaut framework from detecting current environments, while still using any environments that are specifically provided as shown above.
39
-
40
-
.Disabling environment detection via system property
Alternatively, you can disable environment deduction using the api:context.ApplicationContextBuilder[] `deduceEnvironment` method when setting up your application.
47
-
48
-
snippet::io.micronaut.docs.context.env.DefaultEnvironmentSpec[tags="disableEnvDeduction",indent=0,title="Using ApplicationContextBuilder to disable environment deduction"]
49
-
50
-
== Default Environment
51
-
52
-
The Micronaut framework supports the concept of one or many default environments.
53
-
A default environment is one that is only applied if no other environments are explicitly specified or deduced.
54
-
Environments can be explicitly specified either through the application context builder `Micronaut.build().environments(...)`, through the `micronaut.environments` system property, or the `MICRONAUT_ENVIRONMENTS` environment variable.
55
-
Environments can be deduced to automatically apply the environment appropriate for cloud deployments.
56
-
If an environment is found through any of the above means, the default environment will *not* be applied.
57
-
58
-
To set the default environments, include a public static class that implements api:context.ApplicationContextConfigurer[] and is annotated with api:context.annotation.ContextConfigurer[]:
59
-
60
-
[source,java]
61
-
----
62
-
public class Application {
63
-
64
-
@ContextConfigurer
65
-
public static class DefaultEnvironmentConfigurer implements ApplicationContextConfigurer {
66
-
@Override
67
-
public void configure(@NonNull ApplicationContextBuilder builder) {
68
-
builder.defaultEnvironments(defaultEnvironment);
69
-
}
70
-
}
71
-
72
-
public static void main(String[] args) {
73
-
Micronaut.run(Application.class, args);
74
-
}
75
-
}
76
-
----
77
-
78
-
NOTE: Previously, we recommended using `Micronaut.defaultEnvironments("dev")` however this does not allow the Ahead of Time (AOT) compiler to detect the default environments.
79
-
80
-
== Micronaut Banner
81
-
82
-
Since Micronaut framework 2.3 a banner is shown when the application starts. It is enabled by default, and it also shows the Micronaut version.
83
-
84
-
[source,shell,subs="attributes"]
85
-
----
86
-
$ ./gradlew run
87
-
__ __ _ _
88
-
| \/ (_) ___ _ __ ___ _ __ __ _ _ _| |_
89
-
| |\/| | |/ __| '__/ _ \| '_ \ / _` | | | | __|
90
-
| | | | | (__| | | (_) | | | | (_| | |_| | |_
91
-
|_| |_|_|\___|_| \___/|_| |_|\__,_|\__,_|\__|
92
-
Micronaut ({version})
93
-
94
-
17:07:22.997 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 611ms. Server Running: http://localhost:8080
95
-
----
96
-
97
-
To customize the banner with your own ASCII Art (just plain ASCII at this moment), create the file `src/main/resources/micronaut-banner.txt` and it will be used instead.
The Micronaut framework supports the concept of one or many default environments.
2
+
A default environment is one that is only applied if no other environments are explicitly specified or deduced.
3
+
Environments can be explicitly specified either through the application context builder `Micronaut.build().environments(...)`, through the `micronaut.environments` system property, or the `MICRONAUT_ENVIRONMENTS` environment variable.
4
+
Environments can be deduced to automatically apply the environment appropriate for cloud deployments.
5
+
If an environment is found through any of the above means, the default environment will *not* be applied.
6
+
7
+
To set the default environments, include a public static class that implements api:context.ApplicationContextConfigurer[] and is annotated with api:context.annotation.ContextConfigurer[]:
8
+
9
+
[source,java]
10
+
----
11
+
public class Application {
12
+
13
+
@ContextConfigurer
14
+
public static class DefaultEnvironmentConfigurer implements ApplicationContextConfigurer {
15
+
@Override
16
+
public void configure(@NonNull ApplicationContextBuilder builder) {
17
+
builder.defaultEnvironments(defaultEnvironment);
18
+
}
19
+
}
20
+
21
+
public static void main(String[] args) {
22
+
Micronaut.run(Application.class, args);
23
+
}
24
+
}
25
+
----
26
+
27
+
NOTE: Previously, we recommended using `Micronaut.defaultEnvironments("dev")` however this does not allow the Ahead of Time (AOT) compiler to detect the default environments.
Automatic detection of environments can be disabled by setting the `micronaut.env.deduction` system property or the `MICRONAUT_ENV_DEDUCTION` environment variable to `false`. This prevents the Micronaut framework from detecting current environments, while still using any environments that are specifically provided as shown above.
2
+
3
+
.Disabling environment detection via system property
Alternatively, you can disable environment deduction using the api:context.ApplicationContextBuilder[] `deduceEnvironment` method when setting up your application.
10
+
11
+
snippet::io.micronaut.docs.context.env.DefaultEnvironmentSpec[tags="disableEnvDeduction",indent=0,title="Using ApplicationContextBuilder to disable environment deduction"]
The Micronaut framework loads property sources based on the environments specified, and if the same property key exists in multiple property sources specific to an environment, the environment order determines which value to use.
2
+
3
+
The Micronaut framework uses the following hierarchy for environment processing (lowest to highest priority):
4
+
5
+
* Deduced environments
6
+
* Environments from the `micronaut.environments` system property
7
+
* Environments from the `MICRONAUT_ENVIRONMENTS` environment variable
8
+
* Environments specified explicitly through the application context builder
9
+
+
10
+
NOTE: This also applies to `@MicronautTest(environments = ...)`
0 commit comments