id stringlengths 16 145 | text stringlengths 1 179k | title stringclasses 1
value |
|---|---|---|
spring_io/spring_io_10_19.txt | to ` @DataJdbcTest ` but is for tests that use
Spring Data R2DBC repositories. By default, it configures an in-memory
embedded database, an ` R2dbcEntityTemplate ` , and Spring Data R2DBC
repositories. Regular ` @Component ` and ` @ConfigurationProperties ` beans
are not scanned when the ` @DataR2dbcTest ` annotation ... | |
spring_io/bootfeaturesexternal_143_0.txt | Even if the configuration above will create a regular bean for ` FooProperties
` , we recommend that ` @ConfigurationProperties ` only deal with the
environment and in particular does not inject other beans from the context.
Having said that, The ` @EnableConfigurationProperties ` annotation is _also_
automatically ap... | |
spring_io/bootfeaturesexternal1_4_0.txt | Spring Boot uses a very particular ` PropertySource ` order that is designed
to allow sensible overriding of values. Properties are considered in the
following order: | |
spring_io/spring_io_13_6.txt | lliseconds, such as "If a duration suffix is not specified, seconds will be used".
* Do not provide the default value in the description unless it has to be determined at runtime.
Make sure to [ trigger meta-data generation ](configuration-
metadata.html#appendix.configuration-metadata.annotation-processor) so th... | |
spring_io/bootfeaturesexternal_210_0.txt | If you define a set of configuration keys for your own components, we
recommend you to group them in a POJO annotated with `
@ConfigurationProperties ` . Please also be aware that since ` @Value ` does
not support relaxed binding, it isn’t a great candidate if you need to provide
the value using environment variables. | |
spring_io/bootfeaturesexternal1_223_0.txt | public List<MyPojo> getList() {
return this.list;
} | |
spring_io/spring_io_12_0.txt | ## 11\. Testcontainers Support
As well as using Testcontainers for integration testing , it’s also possible
to use them at development time. The next sections will provide more details
about that.
### 11.1. Using Testcontainers at Development Time
This approach allows developers to quickly start containers for t... | |
spring_io/environmentvariables_8_0.txt | [


 | Note
---|--- | |
spring_io/bootfeaturesexternal_53_0.txt | If you have specified any files in ` spring.config.location ` , profile-
specific variants of those files will not be considered. Use directories in `
spring.config.location ` if you also want to also use profile-specific
properties. | |
spring_io/bootfeaturesexternal_190_0.txt | In order to validate values of nested properties, you must annotate the
associated field as ` @Valid ` to trigger its validation. For example,
building upon the above ` FooProperties ` example: | |
spring_io/bootfeaturesexternal1_309_0.txt | [ Prev ](boot-features-spring-application.html) | [ Up ](boot-features.html)
| [ Next ](boot-features-profiles.html)
---|---|---
24\. SpringApplication | [ Home ](index.html) | 26\. Profiles | |
spring_io/bootfeaturesexternal_134_0.txt | * Maps, as long as they are initialized, need a getter but not necessarily a setter since they can be mutated by the binder.
* Collections and arrays can be either accessed via an index (typically with YAML) or using a single comma-separated value (properties). In the latter case, a setter is mandatory. We recommend to... | |
spring_io/bootfeaturesexternal_73_0.txt | To bind to properties like that using the Spring ` DataBinder ` utilities
(which is what ` @ConfigurationProperties ` does) you need to have a property
in the target bean of type ` java.util.List ` (or ` Set ` ) and you either
need to provide a setter, or initialize it with a mutable value, e.g. this
will bind to the p... | |
spring_io/bootfeaturesexternal1_250_0.txt | public Duration getSessionTimeout() {
return this.sessionTimeout;
} | |
spring_io/bootfeaturesexternal_137_0.txt | See also the [ differences between ` @Value ` and ` @ConfigurationProperties `
](boot-features-external-config.html#boot-features-external-config-vs-value
"24.7.5 @ConfigurationProperties vs. @Value") . | |
spring_io/bootfeaturesexternal1_101_0.txt | If you run the application with the arguments ` --spring.profiles.active=dev"
you might expect `security.user.password ` to be set to “secret”, but this is
not the case. | |
spring_io/bootfeaturesexternal1_200_0.txt | ![\[Tip\]](images/tip.png) | Tip
---|--- | |
spring_io/bootfeaturesexternal_83_0.txt | You can specify multiple profile-specific YAML documents in a single file by
using a ` spring.profiles ` key to indicate when the document applies. For
example: | |
spring_io/spring_io_10_15.txt | junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureHttpGraphQlTester;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.graphql.test.tester.HttpGr... | |
spring_io/environmentvariables_23_0.txt | System.out.println(System.getenv("JAVA_HOME")); | |
spring_io/bootfeaturesexternal_101_0.txt | If the ` dev ` profile isn’t active, ` FooProperties.list ` will contain one `
MyPojo ` entry as defined above. If the ` dev ` profile is enabled however,
the ` list ` will _still_ only contain one entry (with name “my another name”
and description ` null ` ). This configuration _will not_ add a second `
MyPojo ` ins... | |
spring_io/bootfeaturesexternal_182_0.txt | Spring will attempt 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 bean
id ` conversionService ` ) or custom property editors (via a `
CustomEditorConfigurer ` ... | |
spring_io/bootfeaturesexternal_10_0.txt | // ... | |
spring_io/bootfeaturesexternal1_174_0.txt | **Table 25.1. relaxed binding** | |
spring_io/bootfeaturesexternal_48_0.txt | ## 24.4 Profile-specific properties | |
spring_io/spring_io_3_3.txt | en be overridden at runtime with a
different file located in one of the custom locations.
#### 2.3.1. Optional Locations
By default, when a specified config data location does not exist, Spring Boot
will throw a ` ConfigDataLocationNotFoundException ` and your application will
not start.
If you want to specify a lo... | |
spring_io/bootfeaturesexternal_178_0.txt | Underscore notation, alternative format for use in ` .properties ` and ` .yml
` files. | |
spring_io/bootfeaturesexternal1_180_0.txt | ` acme.my_project.person.first_name ` | |
spring_io/spring_io_15_2.txt | * Tomcat web server
* Netty web server
To enable reloading, you need to opt-in via a configuration property as shown
in this example:
Properties
spring.ssl.bundle.pem.mybundle.reload-on-update=true
spring.ssl.bundle.pem.mybundle.keystore.certificate=file:/some/directory/application.crt
sp... | |
spring_io/bootfeaturesexternal1_182_0.txt | ` ACME_MYPROJECT_PERSON_FIRSTNAME ` | |
spring_io/bootfeaturesexternal1_244_0.txt | Spring Boot has dedicated support for expressing durations. If you expose a `
java.time.Duration ` property, the following formats in application properties
are available: | |
spring_io/bootfeaturesexternal1_267_0.txt | public DataSize getBufferSize() {
return this.bufferSize;
} | |
spring_io/bootfeaturesexternal_88_0.txt | whereas in this example, the password is always set because it isn’t attached
to any profile, and it would have to be explicitly reset in all other profiles
as necessary: | |
spring_io/bootfeaturesexternal1_9_0.txt | _@Value("${name}")_
private String name; | |
spring_io/bootfeaturesexternal_35_0.txt | $ java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties | |
spring_io/bootfeaturesexternal_81_0.txt | The ` YamlPropertySourceLoader ` class can be used to expose YAML as a `
PropertySource ` in the Spring ` Environment ` . This allows you to use the
familiar ` @Value ` annotation with placeholders syntax to access YAML
properties. | |
spring_io/environmentvariables_41_0.txt |
The source code is [ here ](https://github.com/leeonscoding/spring-boot-env-
example) . | |
spring_io/bootfeaturesexternal1_0_0.txt | 25\. Externalized Configuration
---
[ Prev ](boot-features-spring-application.html) | Part IV. Spring Boot
features | [ Next ](boot-features-profiles.html) | |
spring_io/bootfeaturesexternal_125_0.txt | public String getPassword() { ... } | |
spring_io/environmentvariables_25_0.txt | Spring boot lets us externalize our configuration. We can use the properties
file, yaml file, environment variables and command line arguments to
externalize our configurations. We can directly inject those property values
into our beans by using the ` @Value ` annotation. | |
spring_io/bootfeaturesexternal1_89_0.txt | ![\[Note\]](images/note.png) | Note
---|--- | |
spring_io/bootfeaturesexternal1_302_0.txt | Yes | |
spring_io/spring_io_10_20.txt | factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest
import org.springframework.data.mongodb.core.MongoTemplate
@DataMongoTest
class MyDataMongoDbTests(@Autowired val mongoTemplate: MongoTemplate) {
// ...
}
#### 9.3.2... | |
spring_io/spring_io_13_3.txt | Context ` , or has a `
ConfigurableReactiveWebEnvironment ` .
The ` @ConditionalOnWarDeployment ` and ` @ConditionalOnNotWarDeployment `
annotations let configuration be included depending on whether the application
is a traditional WAR application that is deployed to a servlet container. This
condition will not match... | |
spring_io/bootfeaturesexternal_16_0.txt | $ java -Dspring.application.json='{"foo":"bar"}' -jar myapp.jar | |
spring_io/bootfeaturesexternal_52_0.txt | ![\[Note\]](images/note.png) | Note
---|--- | |
spring_io/bootfeaturesexternal_119_0.txt | public static class Security { | |
spring_io/bootfeaturesexternal1_147_0.txt | _@Component_
_@ConfigurationProperties(prefix="acme")_
public class AcmeProperties { | |
spring_io/bootfeaturesexternal_151_0.txt | _@Service_
public class MyService { | |
spring_io/spring_io_10_29.txt | as they are handled in a specific way by Spring Boot.
---|---
Alternatively, additional auto-configurations can be added for any use of a
slice annotation by registering them in a file stored in ` META-INF/spring `
as shown in the following example:
META-
INF/spring/org.springframework.boot.test.autoconfigure... | |
spring_io/bootfeaturesexternal1_249_0.txt | private Duration readTimeout = Duration.ofMillis(1000); | |
spring_io/bootfeaturesexternal_124_0.txt | public void setUsername(String username) { ... } | |
spring_io/spring_io_3_15.txt | scription: "another description"
---
spring:
config:
activate:
on-profile: "dev"
my:
list:
- name: "my another name"
In the preceding example, if the ` dev ` profile is active, `
MyProperties.list ` contains _one_ ` MyPojo ` entry (with a name of ` my
another name ` and ... | |
spring_io/bootfeaturesexternal1_79_0.txt | To bind to properties like that by using Spring Boot’s ` Binder ` utilities
(which is what ` @ConfigurationProperties ` does), you need to have a property
in the target bean of type ` java.util.List ` (or ` Set ` ) and you either
need to provide a setter or initialize it with a mutable value. For example,
the following... | |
spring_io/bootfeaturesexternal_194_0.txt | // ... getters and setters | |
spring_io/bootfeaturesexternal1_290_0.txt | _@NotEmpty_
public String username; | |
spring_io/bootfeaturesexternal_11_0.txt | On your application classpath (e.g. inside your jar) you can have an `
application.properties ` that provides a sensible default property value for `
name ` . When running in a new environment, an ` application.properties ` can
be provided outside of your jar that overrides the ` name ` ; and for one-off
testing, you c... | |
spring_io/bootfeaturesexternal_54_0.txt | ## 24.5 Placeholders in properties | |
spring_io/bootfeaturesexternal1_110_0.txt | _@ConfigurationProperties("acme")_
public class AcmeProperties { | |
spring_io/spring_io_10_9.txt | a “slice” of your
application. For example, you might want to test that Spring MVC controllers
are mapping URLs correctly, and you do not want to involve database calls in
those tests, or you might want to test JPA entities, and you are not
interested in the web layer when those tests run.
The ` spring-boot-test-autoc... | |
spring_io/bootfeaturesexternal_173_0.txt | ` person.firstName ` | |
spring_io/spring_io_14_0.txt | ## 13\. Kotlin Support
[ Kotlin ](https://kotlinlang.org) is a statically-typed language targeting
the JVM (and other platforms) which allows writing concise and elegant code
while providing [ interoperability
](https://kotlinlang.org/docs/reference/java-interop.html) with existing
libraries written in Java.
Spring ... | |
spring_io/bootfeaturesexternal1_291_0.txt | // ... getters and setters | |
spring_io/spring_io_10_25.txt | framework.test.web.reactive.server.WebTestClient;
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document;
@WebFluxTest
@AutoConfigureRestDocs
class MyUsersDocumentationTests {
@Autowired
private WebTestClient webTestClient;
... | |
spring_io/bootfeaturesexternal1_74_0.txt | environments.dev.url=https://dev.example.com
environments.dev.name=Developer Setup
environments.prod.url=https://another.example.com
environments.prod.name=My Cool App | |
spring_io/bootfeaturesexternal1_159_0.txt | ![\[Tip\]](images/tip.png) | Tip
---|--- | |
spring_io/bootfeaturesexternal_77_0.txt | ![\[Note\]](images/note.png) | Note
---|--- | |
spring_io/bootfeaturesexternal1_141_0.txt | You also need to list the properties classes to register in the `
@EnableConfigurationProperties ` annotation, as shown in the following
example: | |
spring_io/bootfeaturesexternal1_65_0.txt | ## 25.7 Using YAML Instead of Properties | |
spring_io/bootfeaturesexternal1_119_0.txt | public static class Security { | |
spring_io/bootfeaturesexternal1_64_0.txt | If you’re looking for a secure way to store credentials and passwords, the [
Spring Cloud Vault ](https://cloud.spring.io/spring-cloud-vault/) project
provides support for storing externalized configuration in [ HashiCorp Vault
](https://www.vaultproject.io/) . | |
spring_io/bootfeaturesexternal1_17_0.txt | You can also supply the JSON by using a command line argument, as shown in the
following example: | |
spring_io/bootfeaturesexternal1_38_0.txt | ` spring.config.name ` and ` spring.config.location ` are used very early to
determine which files have to be loaded. They must be defined as an
environment property (typically an OS environment variable, a system property,
or a command-line argument). | |
spring_io/bootfeaturesexternal1_303_0.txt | ` SpEL ` evaluation | |
spring_io/bootfeaturesexternal1_152_0.txt | # additional configuration as required | |
spring_io/bootfeaturesexternal1_49_0.txt | ![\[Note\]](images/note.png) | Note
---|--- | |
spring_io/spring_io_10_3.txt | t ` used in your tests. By
default, ` @SpringBootTest ` will not call your ` main ` method, and instead
the class itself is used directly to create the ` ApplicationContext `
If you want to change this behavior, you can change the ` useMainMethod `
attribute of ` @SpringBootTest ` to ` UseMainMethod.ALWAYS ` or `
UseM... | |
spring_io/bootfeaturesexternal1_271_0.txt | To specify a buffer size of 10 megabytes, ` 10 ` and ` 10MB ` are equivalent.
A size threshold of 256 bytes can be specified as ` 256 ` or ` 256B ` . | |
spring_io/spring_io_6_0.txt | ## 5\. Internationalization
Spring Boot supports localized messages so that your application can cater to
users of different language preferences. By default, Spring Boot looks for the
presence of a ` messages ` resource bundle at the root of the classpath.
__ | The auto-configuration applies when the default prope... | |
spring_io/environmentvariables_3_0.txt | # [ leeon's coding ](/?source=top_nav_blog_home) | |
spring_io/bootfeaturesexternal_161_0.txt | _@ConfigurationProperties(prefix = "bar")_
_@Bean_
public BarComponent barComponent() {
...
} | |
spring_io/spring_io_2_1.txt | ded servlet container failed to start. Port 8080 was already in use.
Action:
Identify and stop the process that is listening on port 8080 or configure this application to listen on another port.
__ | Spring Boot provides numerous ` FailureAnalyzer ` implementations, and you can [ add your own ](howt... | |
spring_io/spring_io_2_7.txt | be passed to ` System.exit() ` to return it as a status code, as
shown in the following example:
Java
import org.springframework.boot.ExitCodeGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springfr... | |
spring_io/bootfeaturesexternal1_85_0.txt | ### 25.7.3 Multi-profile YAML Documents | |
spring_io/bootfeaturesexternal_90_0.txt | Spring profiles designated using the "spring.profiles" element may optionally
be negated using the ` ! ` character. If both negated and non-negated profiles
are specified for a single document, at least one non-negated profile must
match and no negated profiles may match. | |
spring_io/bootfeaturesexternal1_102_0.txt | The nested document will be filtered because the main file is named `
application-dev.yml ` . It is already considered to be profile-specific, and
nested documents will be ignored. | |
spring_io/bootfeaturesexternal_15_0.txt | In this example you will end up with ` foo.bar=spam ` in the Spring `
Environment ` . You can also supply the JSON as ` spring.application.json ` in
a System variable: | |
spring_io/bootfeaturesexternal_104_0.txt | In the example above, considering that the ` dev ` profile is active, `
FooProperties.list ` will contain _one_ ` MyPojo ` entry (with name “my
another name” and description ` null ` ). | |
spring_io/bootfeaturesexternal_158_0.txt | ### 24.7.1 Third-party configuration | |
spring_io/bootfeaturesexternal1_206_0.txt | ![\[Note\]](images/note.png) | Note
---|--- | |
spring_io/spring_io_10_22.txt | n building
the ` RestTemplate ` , then the root URI should be omitted from the `
MockRestServiceServer ` expectations as shown in the following example:
Java
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.tes... | |
spring_io/bootfeaturesexternal1_35_0.txt | The following example shows how to specify two locations: | |
spring_io/spring_io_8_0.txt | ## 7\. JSON
Spring Boot provides integration with three JSON mapping libraries:
* Gson
* Jackson
* JSON-B
Jackson is the preferred and default library.
### 7.1. Jackson
Auto-configuration for Jackson is provided and Jackson is part of ` spring-
boot-starter-json ` . When Jackson is on the classpath an... | |
spring_io/bootfeaturesexternal1_184_0.txt | ![\[Note\]](images/note.png) | Note
---|--- | |
spring_io/bootfeaturesexternal1_140_0.txt | See also the [ differences between ` @Value ` and ` @ConfigurationProperties `
](boot-features-external-config.html#boot-features-external-config-vs-value
"25.8.6 @ConfigurationProperties vs. @Value") . | |
spring_io/bootfeaturesexternal_2_0.txt | ## 24\. Externalized Configuration | |
spring_io/bootfeaturesexternal1_145_0.txt | The bean name in the example above is ` acme-com.example.AcmeProperties ` . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.