id
stringlengths
16
145
text
stringlengths
1
179k
title
stringclasses
1 value
spring_io/bootfeaturesexternal_80_0.txt
### 24.6.2 Exposing YAML as properties in the Spring Environment
spring_io/bootfeaturesexternal_192_0.txt
_@NotNull_ private InetAddress remoteAddress;
spring_io/bootfeaturesexternal1_10_0.txt
// ...
spring_io/bootfeaturesexternal1_298_0.txt
[ Relaxed binding ](boot-features-external-config.html#boot-features-external- config-relaxed-binding "25.8.2 Relaxed Binding")
spring_io/bootfeaturesexternal_8_0.txt
_@Component_ public class MyBean {
spring_io/bootfeaturesexternal1_142_0.txt
_@Configuration_ _@EnableConfigurationProperties(AcmeProperties.class)_ public class MyConfiguration { }
spring_io/bootfeaturesexternal1_188_0.txt
Properties Files
spring_io/spring_io_9_0.txt
## 8\. Task Execution and Scheduling In the absence of an ` Executor ` bean in the context, Spring Boot auto- configures an ` AsyncTaskExecutor ` . When virtual threads are enabled (using Java 21+ and ` spring.threads.virtual.enabled ` set to ` true ` ) this will be a ` SimpleAsyncTaskExecutor ` that uses virtual thr...
spring_io/bootfeaturesexternal1_75_0.txt
YAML lists are represented as property keys with ` [index] ` dereferencers. For example, consider the following YAML:
spring_io/bootfeaturesexternal1_157_0.txt
//...
spring_io/bootfeaturesexternal_71_0.txt
Would be transformed into these properties:
spring_io/bootfeaturesexternal1_301_0.txt
[ Meta-data support ](configuration-metadata.html "Appendix B. Configuration Metadata")
spring_io/bootfeaturesexternal1_220_0.txt
For example, assume a ` MyPojo ` object with ` name ` and ` description ` attributes that are ` null ` by default. The following example exposes a list of ` MyPojo ` objects from ` AcmeProperties ` :
spring_io/bootfeaturesexternal1_205_0.txt
The properties above will bind to a ` Map ` with ` /key1 ` , ` /key2 ` and ` key3 ` as the keys in the map.
spring_io/spring_io_14_2.txt
MockK ](https://github.com/Ninja-Squad/springmockk) which provides similar ` @MockkBean ` and ` @SpykBean ` annotations. ### 13.7. Resources #### 13.7.1. Further reading * [ Kotlin language reference ](https://kotlinlang.org/docs/reference/) * [ Kotlin Slack ](https://kotlinlang.slack.com/) (with a dedicated ...
spring_io/bootfeaturesexternal1_116_0.txt
public InetAddress getRemoteAddress() { ... }
spring_io/bootfeaturesexternal1_295_0.txt
### 25.8.6 @ConfigurationProperties vs. @Value
spring_io/spring_io_13_2.txt
tions let a bean be included based on the presence or absence of specific beans. You can use the ` value ` attribute to specify beans by type or ` name ` to specify beans by name. The ` search ` attribute lets you limit the ` ApplicationContext ` hierarchy that should be considered when searching for beans. When place...
spring_io/bootfeaturesexternal1_227_0.txt
When a ` List ` is specified in multiple profiles, the one with the highest priority (and only that one) is used. Consider the following example:
spring_io/bootfeaturesexternal1_20_0.txt
## 25.1 Configuring Random Values
spring_io/bootfeaturesexternal_183_0.txt
![\[Note\]](images/note.png) | Note ---|---
spring_io/environmentvariables_19_0.txt
Environment variables are key-value pairs. Java provides a static method called System.getEnv() which returns an unmodifiable map. This map contains the environment variables and their corresponding values as a key-value pair. If we don't pass an argument in System.getenv() then it will retrieve all the environment var...
spring_io/bootfeaturesexternal1_234_0.txt
Consider the following configuration:
spring_io/bootfeaturesexternal1_270_0.txt
public void setSizeThreshold(DataSize sizeThreshold) { this.sizeThreshold = sizeThreshold; }
spring_io/bootfeaturesexternal1_266_0.txt
private DataSize sizeThreshold = DataSize.ofBytes(512);
spring_io/bootfeaturesexternal1_242_0.txt
As this bean is requested very early during the application lifecycle, make sure to limit the dependencies that your ` ConversionService ` is using. Typically, any dependency that you require may not be fully initialized at creation time. You may want to rename your custom ` ConversionService ` if it is not required fo...
spring_io/bootfeaturesexternal_17_0.txt
or command line argument:
spring_io/bootfeaturesexternal_197_0.txt
// ... getters and setters
spring_io/bootfeaturesexternal_28_0.txt
` SpringApplication ` will load properties from ` application.properties ` files in the following locations and add them to the Spring ` Environment ` :
spring_io/bootfeaturesexternal1_280_0.txt
_@NotNull_ private InetAddress remoteAddress;
spring_io/environmentvariables_18_0.txt
### Environment Variables in Java
spring_io/environmentvariables_35_0.txt
### Environment class
spring_io/bootfeaturesexternal_103_0.txt
foo: list: - name: my name description: my description - name: another name description: another description --- spring: profiles: dev foo: list: - name: my another name
spring_io/bootfeaturesexternal_69_0.txt
YAML lists are represented as property keys with ` [index] ` dereferencers, for example this YAML:
spring_io/spring_io_10_27.txt
ocs.restassured.RestAssuredRestDocumentationConfigurer; import org.springframework.restdocs.templates.TemplateFormats; @TestConfiguration(proxyBeanMethods = false) public class MyRestDocsConfiguration implements RestDocsRestAssuredConfigurationCustomizer { @Override public void cus...
spring_io/bootfeaturesexternal1_224_0.txt
Consider the following configuration:
spring_io/bootfeaturesexternal1_299_0.txt
Yes
spring_io/bootfeaturesexternal_187_0.txt
_@ConfigurationProperties(prefix="foo")_ _@Validated_ public class FooProperties {
spring_io/bootfeaturesexternal1_219_0.txt
When lists are configured in more than one place, overriding works by replacing the entire list.
spring_io/bootfeaturesexternal1_170_0.txt
private String firstName;
spring_io/spring_io_3_2.txt
er items overriding earlier ones). Documents from the loaded files are added as ` PropertySources ` to the Spring ` Environment ` . If you do not like ` application ` as the configuration file name, you can switch to another file name by specifying a ` spring.config.name ` environment property. For example, to look fo...
spring_io/spring_io_2_5.txt
ApplicationListener=com.example.project.MyListener ---|--- Application events are sent in the following order, as your application runs: 1. An ` ApplicationStartingEvent ` is sent at the start of a run but before any processing, except for the registration of listeners and initializers. 2. An ` Applica...
spring_io/environmentvariables_31_0.txt
@Value("${java.home}") private String envViaProperties;
spring_io/spring_io_11_0.txt
## 10\. Docker Compose Support Docker Compose is a popular technology that can be used to define and manage multiple containers for services that your application needs. A ` compose.yml ` file is typically created next to your application which defines and configures service containers. A typical workflow with Docke...
spring_io/bootfeaturesexternal_206_0.txt
[ Meta-data support ](configuration-metadata.html "Appendix B. Configuration meta-data")
spring_io/bootfeaturesexternal1_72_0.txt
environments: dev: url: https://dev.example.com name: Developer Setup prod: url: https://another.example.com name: My Cool App
spring_io/bootfeaturesexternal1_53_0.txt
Profile-specific properties are loaded from the same locations as standard ` application.properties ` , with profile-specific files always overriding the non-specific ones, whether or not the profile-specific files are inside or outside your packaged jar.
spring_io/bootfeaturesexternal1_240_0.txt
Spring Boot attempts to coerce the external application properties to the right type when it binds to the ` @ConfigurationProperties ` beans. If you need custom type conversion, you can provide a ` ConversionService ` bean (with a bean named ` conversionService ` ) or custom property editors (through a ` CustomEditorCo...
spring_io/spring_io_2_8.txt
ationStartup(new BufferingApplicationStartup(2048)); application.run(args); } } Kotlin import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup import org.springfram...
spring_io/spring_io_7_0.txt
## 6\. Aspect-Oriented Programming Spring Boot provides auto-configuration for aspect-oriented programming (AOP). You can learn more about AOP with Spring in the [ Spring Framework reference documentation ](https://docs.spring.io/spring- framework/reference/6.1/core/aop-api.html) . By default, Spring Boot’s auto-con...
spring_io/spring_io_10_10.txt
Kotlin import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.json.JsonTest import org.springframework.boot.test.json.JacksonTester @JsonT...
spring_io/spring_io_10_21.txt
; @DataRedisTest class MyDataRedisTests { @Autowired private SomeRepository repository; // ... } Kotlin import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.data.redis.DataRedisTe...
spring_io/bootfeaturesexternal_68_0.txt
environments.dev.url=http://dev.bar.com environments.dev.name=Developer Setup environments.prod.url=http://foo.bar.com environments.prod.name=My Cool App
spring_io/bootfeaturesexternal_105_0.txt
## 24.7 Type-safe Configuration Properties
spring_io/bootfeaturesexternal1_96_0.txt
### 25.7.4 YAML Shortcomings
spring_io/spring_io_10_18.txt
ort org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @DataJpaTest @AutoConfigureTestDatabase(replace = Replace.NONE) class MyRepositoryTests { // ... } Kotlin import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase ...
spring_io/bootfeaturesexternal_140_0.txt
![\[Note\]](images/note.png) | Note ---|---
spring_io/bootfeaturesexternal_111_0.txt
private boolean enabled;
spring_io/bootfeaturesexternal_175_0.txt
` person.first-name `
spring_io/spring_io_10_26.txt
nfiguration import org.springframework.boot.test.web.reactive.server.WebTestClientBuilderCustomizer import org.springframework.context.annotation.Bean import org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation import org.springframework.test.web.reactive.server.WebTestClient ...
spring_io/bootfeaturesexternal1_202_0.txt
#### Binding Maps
spring_io/spring_io_11_2.txt
e ` spring.docker.compose.start.command ` property to change whether ` docker compose up ` or ` docker compose start ` is used. The ` spring.docker.compose.stop.command ` allows you to configure if ` docker compose down ` or ` docker compose stop ` is used. The following example shows how lifecycle management can be c...
spring_io/bootfeaturesexternal1_308_0.txt
* * *
spring_io/bootfeaturesexternal1_196_0.txt
Numeric values surrounded by underscores (see [ the section called “Binding from Environment Variables” ](boot-features-external-config.html#boot- features-external-config-relaxed-binding-from-environment-variables "Binding from Environment Variables") )`
spring_io/bootfeaturesexternal_205_0.txt
Yes
spring_io/environmentvariables_6_0.txt
![Environment variables in Java and Spring boot](https://cdn.hashnode.com/res/hashnode/image/upload/v1684253711877/3d4add85-84da-4fd9-a237-f947f44a4a4c.png?w=1600&h=840&fit=crop&crop=entropy&auto=compress,format&format=webp) ![Environment variables in Java and Spring boot](https://cdn.hashnode.com/res/hashnode/image/up...
spring_io/spring_io_1_0.txt
Dark Theme # Core Features Table of Contents [ Back to index ](index.html) * 1\. SpringApplication * 1.1. Startup Failure * 1.2. Lazy Initialization * 1.3. Customizing the Banner * 1.4. Customizing SpringApplication * 1.5. Fluent Builder API * 1.6. Application Availability * ...
spring_io/bootfeaturesexternal_189_0.txt
// ... getters and setters
spring_io/bootfeaturesexternal1_189_0.txt
Camel case, kebab case, or underscore notation
spring_io/bootfeaturesexternal1_165_0.txt
Any property defined with the ` another ` prefix is mapped onto that ` AnotherComponent ` bean in manner similar to the preceding ` AcmeProperties ` example.
spring_io/bootfeaturesexternal_110_0.txt
_@ConfigurationProperties("foo")_ public class FooProperties {
spring_io/bootfeaturesexternal_208_0.txt
` SpEL ` evaluation
spring_io/bootfeaturesexternal_201_0.txt
### 24.7.5 @ConfigurationProperties vs. @Value
spring_io/bootfeaturesexternal_98_0.txt
public List<MyPojo> getList() { return this.list; }
spring_io/bootfeaturesexternal1_277_0.txt
### 25.8.5 @ConfigurationProperties Validation
spring_io/bootfeaturesexternal1_37_0.txt
![\[Warning\]](images/warning.png) | Warning ---|---
spring_io/bootfeaturesexternal1_130_0.txt
The preceding POJO defines the following properties:
spring_io/bootfeaturesexternal_65_0.txt
For example, the following YAML document:
spring_io/bootfeaturesexternal1_260_0.txt
#### Converting Data Sizes
spring_io/spring_io_3_8.txt
ent classes that can be used to load YAML documents. The ` YamlPropertiesFactoryBean ` loads YAML as ` Properties ` and the ` YamlMapFactoryBean ` loads YAML as a ` Map ` . You can also use the ` YamlPropertySourceLoader ` class if you want to load YAML as a Spring ` PropertySource ` . ### 2.6. Configuring Random Va...
spring_io/bootfeaturesexternal1_123_0.txt
public String getUsername() { ... }
spring_io/bootfeaturesexternal1_73_0.txt
The preceding example would be transformed into the following properties:
spring_io/environmentvariables_9_0.txt
[ Asfaq Leeon ](https://hashnode.com/@leeonscoding)
spring_io/spring_io_10_13.txt
framework.boot.test.autoconfigure.web.reactive.WebFluxTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.test.web.reactive.server.WebTestClient; import static org.mockito.BDDMockito.given; @WebFluxTest(Use...
spring_io/bootfeaturesexternal_57_0.txt
![\[Tip\]](images/tip.png) | Tip ---|---
spring_io/bootfeaturesexternal_174_0.txt
Standard camel case syntax.
spring_io/bootfeaturesexternal1_121_0.txt
private String password;
spring_io/bootfeaturesexternal_176_0.txt
Dashed notation, recommended for use in ` .properties ` and ` .yml ` files.
spring_io/bootfeaturesexternal_172_0.txt
Property | Note ---|---
spring_io/bootfeaturesexternal_133_0.txt
Getters and setters are usually mandatory, since binding is via standard Java Beans property descriptors, just like in Spring MVC. There are cases where a setter may be omitted:
spring_io/bootfeaturesexternal1_307_0.txt
Finally, while you can write a ` SpEL ` expression in ` @Value ` , such expressions are not processed from [ application property files ](boot- features-external-config.html#boot-features-external-config-application- property-files "25.3 Application Property Files") .
spring_io/bootfeaturesexternal1_21_0.txt
The ` RandomValuePropertySource ` is useful for injecting random values (for example, into secrets or test cases). It can produce integers, longs, uuids, or strings, as shown in the following example:
spring_io/bootfeaturesexternal1_185_0.txt
The ` prefix ` value for the annotation _must_ be in kebab case (lowercase and separated by ` - ` , such as ` acme.my-project.person ` ).
spring_io/bootfeaturesexternal1_296_0.txt
The ` @Value ` annotation is a core container feature, and it does not provide the same features as type-safe configuration properties. The following table summarizes the features that are supported by ` @ConfigurationProperties ` and ` @Value ` :
spring_io/bootfeaturesexternal_45_0.txt
If you use environment variables rather than system properties, most operating systems disallow period-separated key names, but you can use underscores instead (e.g. ` SPRING_CONFIG_NAME ` instead of ` spring.config.name ` ).
spring_io/bootfeaturesexternal1_15_0.txt
In the preceding example, you end up with ` acme.name=test ` in the Spring ` Environment ` . You can also supply the JSON as ` spring.application.json ` in a System property, as shown in the following example:
spring_io/bootfeaturesexternal_168_0.txt
public String getFirstName() { return this.firstName; }
spring_io/bootfeaturesexternal1_44_0.txt
Alternatively, when custom config locations are configured by using ` spring.config.additional-location ` , they are used in addition to the default locations. Additional locations are searched before the default locations. For example, if additional locations of ` classpath:/custom-config/,file:./custom- config/ ` are...
spring_io/bootfeaturesexternal1_171_0.txt
public String getFirstName() { return this.firstName; }
spring_io/bootfeaturesexternal1_285_0.txt
_@ConfigurationProperties(prefix="acme")_ _@Validated_ public class AcmeProperties {