id stringlengths 16 145 | text stringlengths 1 179k | title stringclasses 1
value |
|---|---|---|
spring_io/bootfeaturesexternal1_236_0.txt | If the ` dev ` profile is not active, ` AcmeProperties.map ` contains one
entry with key ` key1 ` (with a name of ` my name 1 ` and a description of `
my description 1 ` ). If the ` dev ` profile is enabled, however, ` map `
contains two entries with keys ` key1 ` (with a name of ` dev name 1 ` and a
description of ` m... | |
spring_io/bootfeaturesexternal_14_0.txt | $ SPRING_APPLICATION_JSON='{"foo":{"bar":"spam"}}' java -jar myapp.jar | |
spring_io/bootfeaturesexternal1_221_0.txt | _@ConfigurationProperties("acme")_
public class AcmeProperties { | |
spring_io/bootfeaturesexternal1_254_0.txt | To specify a session timeout of 30 seconds, ` 30 ` , ` PT30S ` and ` 30s ` are
all equivalent. A read timeout of 500ms can be specified in any of the
following form: ` 500 ` , ` PT0.5S ` and ` 500ms ` . | |
spring_io/bootfeaturesexternal1_40_0.txt | Config locations are searched in reverse order. By default, the configured
locations are ` classpath:/,classpath:/config/,file:./,file:./config/ ` . The
resulting search order is the following: | |
spring_io/bootfeaturesexternal1_160_0.txt | Using ` @ConfigurationProperties ` also lets you generate metadata files that
can be used by IDEs to offer auto-completion for your own keys. See the [
Appendix B, _Configuration Metadata_ ](configuration-metadata.html
"Appendix B. Configuration Metadata") appendix for details. | |
spring_io/bootfeaturesexternal_204_0.txt | [ Relaxed binding ](boot-features-external-config.html#boot-features-external-
config-relaxed-binding "24.7.2 Relaxed binding") | |
spring_io/bootfeaturesexternal1_284_0.txt | To ensure that validation is always triggered for nested properties, even when
no properties are found, the associated field must be annotated with ` @Valid
` . The following example builds on the preceding ` AcmeProperties ` example: | |
spring_io/environmentvariables_37_0.txt | @SpringBootTest
public class DefaultEnvClassTest {
@Autowired
private Environment environment; | |
spring_io/bootfeaturesexternal_39_0.txt | Config locations are searched in reverse order. By default, the configured
locations are ` classpath:/,classpath:/config/,file:./,file:./config/ ` . The
resulting search order is: | |
spring_io/bootfeaturesexternal1_156_0.txt | _@Autowired_
public MyService(AcmeProperties properties) {
this.properties = properties;
} | |
spring_io/bootfeaturesexternal_74_0.txt | _@ConfigurationProperties(prefix="my")_
public class Config { | |
spring_io/bootfeaturesexternal1_167_0.txt | Spring Boot uses some relaxed rules for binding ` Environment ` properties to
` @ConfigurationProperties ` beans, so there does not need to be an exact
match between the ` Environment ` property name and the bean property name.
Common examples where this is useful include dash-separated environment
properties (for exam... | |
spring_io/bootfeaturesexternal1_155_0.txt | private final AcmeProperties properties; | |
spring_io/bootfeaturesexternal1_135_0.txt | Getters and setters are usually mandatory, since binding is through standard
Java Beans property descriptors, just like in Spring MVC. A setter may be
omitted in the following cases: | |
spring_io/bootfeaturesexternal_116_0.txt | public InetAddress getRemoteAddress() { ... } | |
spring_io/bootfeaturesexternal1_241_0.txt | ![\[Note\]](images/note.png) | Note
---|--- | |
spring_io/bootfeaturesexternal1_243_0.txt | #### Converting durations | |
spring_io/environmentvariables_24_0.txt |
### Environment variables in spring boot | |
spring_io/bootfeaturesexternal1_57_0.txt | ## 25.5 Placeholders in Properties | |
spring_io/environmentvariables_40_0.txt | @Test
public void testWithJavaLangMethod() {
Assertions.assertEquals("C:\\Program Files\\Java\\jdk-17.0.5", System.getenv("JAVA_HOME"));
} | |
spring_io/bootfeaturesexternal1_204_0.txt | acme:
map:
"[/key1]": value1
"[/key2]": value2
/key3: value3 | |
spring_io/bootfeaturesexternal1_117_0.txt | public void setRemoteAddress(InetAddress remoteAddress) { ... } | |
spring_io/spring_io_3_9.txt | }
public void setPassword(String password) {
this.password = password;
}
public List<String> getRoles() {
return this.roles;
}
public void setRoles(List<String> roles) {
this.roles = roles;
... | |
spring_io/bootfeaturesexternal1_173_0.txt | With the preceding code, the following properties names can all be used: | |
spring_io/bootfeaturesexternal_5_0.txt | 1. [ Devtools global settings properties ](using-boot-devtools.html#using-boot-devtools-globalsettings "20.4 Global settings") on your home directory ( ` ~/.spring-boot-devtools.properties ` when devtools is active).
2. [ ` @TestPropertySource ` ](https://docs.spring.io/spring/docs/4.3.10.RELEASE/javadoc-api/org/spring... | |
spring_io/bootfeaturesexternal1_304_0.txt | Yes | |
spring_io/bootfeaturesexternal1_14_0.txt | $ SPRING_APPLICATION_JSON='{"acme":{"name":"test"}}' java -jar myapp.jar | |
spring_io/bootfeaturesexternal1_24_0.txt | ## 25.2 Accessing Command Line Properties | |
spring_io/bootfeaturesexternal1_105_0.txt | ## 25.8 Type-safe Configuration Properties | |
spring_io/bootfeaturesexternal_160_0.txt | To configure a bean from the ` Environment ` properties, add `
@ConfigurationProperties ` to its bean registration: | |
spring_io/environmentvariables_28_0.txt | We can also use our environment variables in properties files too. Today I'm
using the spring-boot provided [ application.properties
](http://application.properties) file. | |
spring_io/spring_io_10_28.txt | spond(ResponseCreators.withPayload(StringSource("<response><status>200</status></response>")))
assertThat(this.someWebService.test()).extracting(Response::status).isEqualTo(200)
}
}
##### Auto-configured Spring Web Services Server Tests
You can use ` @WebServiceServerTest ` to test ... | |
spring_io/bootfeaturesexternal_66_0.txt | environments:
dev:
url: http://dev.bar.com
name: Developer Setup
prod:
url: http://foo.bar.com
name: My Cool App | |
spring_io/spring_io_13_1.txt | r for auto-configuration classes.
As with standard ` @Configuration ` classes, the order in which auto-
configuration classes are applied only affects the order in which their beans
are defined. The order in which those beans are subsequently created is
unaffected and is determined by each bean’s dependencies and any ... | |
spring_io/bootfeaturesexternal1_194_0.txt | Environment Variables | |
spring_io/spring_io_3_16.txt | \(java.lang.CharSequence\))
* A more readable format where the value and the unit are coupled ( ` 10s ` means 10 seconds)
Consider the following example:
Java
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import org.springframework.boot.context.properties.Configurati... | |
spring_io/bootfeaturesexternal1_84_0.txt | The ` YamlPropertySourceLoader ` class can be used to expose YAML as a `
PropertySource ` in the Spring ` Environment ` . Doing so lets you use the `
@Value ` annotation with placeholders syntax to access YAML properties. | |
spring_io/bootfeaturesexternal1_66_0.txt | [ YAML ](https://yaml.org) is a superset of JSON and, as such, is a convenient
format for specifying hierarchical configuration data. The ` SpringApplication
` class automatically supports YAML as an alternative to properties whenever
you have the [ SnakeYAML ](https://bitbucket.org/asomov/snakeyaml) library on
your cl... | |
spring_io/bootfeaturesexternal1_163_0.txt | To configure a bean from the ` Environment ` properties, add `
@ConfigurationProperties ` to its bean registration, as shown in the following
example: | |
spring_io/bootfeaturesexternal1_134_0.txt | ![\[Note\]](images/note.png) | Note
---|--- | |
spring_io/bootfeaturesexternal1_186_0.txt | **Table 25.2. relaxed binding rules per property source** | |
spring_io/bootfeaturesexternal_132_0.txt | ![\[Note\]](images/note.png) | Note
---|--- | |
spring_io/bootfeaturesexternal1_81_0.txt | private List<String> servers = new ArrayList<String>(); | |
spring_io/environmentvariables_17_0.txt | The advantage is that those things are changed frequently. We don't need to
redeploy the application, just change the variable value. | |
spring_io/bootfeaturesexternal_148_0.txt | foo:
remote-address: 192.168.1.1
security:
username: foo
roles:
- USER
- ADMIN | |
spring_io/spring_io_3_4.txt | ` classpath:/cfg/,classpath:/ext/
` we process all ` /cfg ` files before all ` /ext ` files:
1. ` /cfg/application-live.properties `
2. ` /ext/application-prod.properties `
3. ` /ext/application-live.properties `
When we have ` classpath:/cfg/;classpath:/ext/ ` instead (with a ` ; `
delimiter) we process ` /cf... | |
spring_io/bootfeaturesexternal1_62_0.txt | ## 25.6 Encrypting Properties | |
spring_io/bootfeaturesexternal1_166_0.txt | ### 25.8.2 Relaxed Binding | |
spring_io/spring_io_10_12.txt | Honda Civic");
}
}
Kotlin
import com.gargoylesoftware.htmlunit.WebClient
import com.gargoylesoftware.htmlunit.html.HtmlPage
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.mockito.BDDMockito.given
import org.springf... | |
spring_io/bootfeaturesexternal1_30_0.txt | The list is ordered by precedence (properties defined in locations higher in
the list override those defined in lower locations). | |
spring_io/bootfeaturesexternal_55_0.txt | The values in ` application.properties ` are filtered through the existing `
Environment ` when they are used so you can refer back to previously defined
values (e.g. from System properties). | |
spring_io/spring_io_13_4.txt | vice.class);
assertThat(context.getBean(MyService.class).getName()).isEqualTo("test123");
});
}
Kotlin
@Test
fun serviceNameCanBeConfigured() {
contextRunner.withPropertyValues("user.name=test123").run { context: AssertableApplicationContext ->
assert... | |
spring_io/spring_io_15_0.txt | ## 14\. SSL
Spring Boot provides the ability to configure SSL trust material that can be
applied to several types of connections in order to support secure
communications. Configuration properties with the prefix ` spring.ssl.bundle `
can be used to specify named sets of trust material and associated
information.
##... | |
spring_io/spring_io_4_1.txt | erties
spring.profiles.include[0]=common
spring.profiles.include[1]=local
Yaml
spring:
profiles:
include:
- "common"
- "local"
__ | Similar to ` spring.profiles.active ` , ` spring.profiles.include ` can only be used in non-profile specific document... | |
spring_io/bootfeaturesexternal_181_0.txt | ### 24.7.3 Properties conversion | |
spring_io/bootfeaturesexternal1_261_0.txt | Spring Framework has a ` DataSize ` value type that expresses a size in bytes.
If you expose a ` DataSize ` property, the following formats in application
properties are available: | |
spring_io/bootfeaturesexternal1_176_0.txt | ` acme.my-project.person.first-name ` | |
spring_io/bootfeaturesexternal1_306_0.txt | If you do want to use ` @Value ` , we recommend that you refer to property
names using their canonical form (kebab-case using only lowercase letters).
This will allow Spring Boot to use the same logic as it does when relaxed
binding ` @ConfigurationProperties ` . For example, ` @Value("{demo.item-
price}") ` will pick ... | |
spring_io/bootfeaturesexternal_128_0.txt | public void setRoles(List<String> roles) { ... } | |
spring_io/bootfeaturesexternal_46_0.txt | ![\[Note\]](images/note.png) | Note
---|--- | |
spring_io/bootfeaturesexternal1_272_0.txt | You can also use any of the supported units. These are: | |
spring_io/bootfeaturesexternal1_178_0.txt | ` acme.myProject.person.firstName ` | |
spring_io/bootfeaturesexternal_12_0.txt | ![\[Tip\]](images/tip.png) | Tip
---|--- | |
spring_io/bootfeaturesexternal_13_0.txt | The ` SPRING_APPLICATION_JSON ` properties can be supplied on the command line
with an environment variable. For example in a UN*X shell: | |
spring_io/bootfeaturesexternal1_77_0.txt | The preceding example would be transformed into these properties: | |
spring_io/bootfeaturesexternal1_124_0.txt | public void setUsername(String username) { ... } | |
spring_io/bootfeaturesexternal1_183_0.txt | Upper case format, which is recommended when using system environment
variables. | |
spring_io/spring_io_3_11.txt | ` )
---|---
__ | To use constructor binding in a native image the class must be compiled with ` -parameters ` . This will happen automatically if you use Spring Boot’s Gradle plugin or if you use Maven and ` spring-boot-starter-parent ` .
---|---
__ | The use of ` java.util.Optional ` with ` @Configur... | |
spring_io/spring_io_2_2.txt | SI escape code. See [ ` AnsiPropertySource ` ](https://github.com/spring-projects/spring-boot/tree/v3.2.4/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiPropertySource.java) for details.
` ${application.title} ` | The title of your application, as declared in ` MANIFEST.MF ` . For e... | |
spring_io/bootfeaturesexternal_58_0.txt | You can also use this technique to create ‘short’ variants of existing Spring
Boot properties. See the _[ Section 72.4, “Use ‘short’ command line
arguments” ](howto-properties-and-configuration.html#howto-use-short-command-
line-arguments "72.4 Use ‘short’ command line arguments") _ how-to for
details. | |
spring_io/spring_io_10_24.txt | tBuilders.get("/users").accept(MediaType.TEXT_PLAIN))
.andExpect(MockMvcResultMatchers.status().isOk)
.andDo(MockMvcRestDocumentation.document("list-users"))
}
}
If you require more control over Spring REST Docs configuration than offered
by the attributes of ` @Au... | |
spring_io/bootfeaturesexternal_95_0.txt | For example, assume a ` MyPojo ` object with ` name ` and ` description `
attributes that are ` null ` by default. Let’s expose a list of ` MyPojo `
from ` FooProperties ` : | |
spring_io/bootfeaturesexternal1_237_0.txt | ![\[Note\]](images/note.png) | Note
---|--- | |
spring_io/bootfeaturesexternal1_201_0.txt | We recommend that, when possible, properties are stored in lower-case kebab
format, such as ` my.property-name=acme ` . | |
spring_io/bootfeaturesexternal1_58_0.txt | The values in ` application.properties ` are filtered through the existing `
Environment ` when they are used, so you can refer back to previously defined
values (for example, from System properties). | |
spring_io/spring_io_12_1.txt | ngframework.boot.SpringApplication;
public class TestMyApplication {
public static void main(String[] args) {
SpringApplication.from(MyApplication::main).with(MyContainersConfiguration.class).run(args);
}
}
Kotlin
import org.springframework.boot.fr... | |
spring_io/spring_io_10_8.txt | MyTests {
// ...
}
Kotlin
import org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener
import org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener
import org.springframework.test.context.ContextConfiguration
import org.sprin... | |
spring_io/spring_io_10_1.txt | tion works by
creating the ` ApplicationContext ` used in your tests through `
SpringApplication ` . In addition to ` @SpringBootTest ` a number of other
annotations are also provided for testing more specific slices of an
application.
__ | If you are using JUnit 4, do not forget to also add ` @RunWith(SpringRunner... | |
spring_io/bootfeaturesexternal1_114_0.txt | public boolean isEnabled() { ... } | |
spring_io/bootfeaturesexternal_122_0.txt | private List<String> roles = new ArrayList<>(Collections.singleton("USER")); | |
spring_io/bootfeaturesexternal_200_0.txt | The ` spring-boot-actuator ` module includes an endpoint that exposes all `
@ConfigurationProperties ` beans. Simply point your web browser to `
/configprops ` or use the equivalent JMX endpoint. See the _[ Production
ready features ](production-ready-endpoints.html "47. Endpoints") _ . section
for details. | |
spring_io/spring_io_10_11.txt | he following example uses ` MockMvc ` :
---|---
Java
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.Mock... | |
spring_io/bootfeaturesexternal1_92_0.txt | server:
port: 8000
---
spring:
profiles: default
security:
user:
password: weak | |
spring_io/bootfeaturesexternal1_276_0.txt | If you are upgrading from a previous version that is using ` Long ` to express
the size, make sure to define the unit (using ` @DataSizeUnit ` ) if it isn’t
bytes alongsidethe switch to ` DataSize ` . Doing so gives a transparent
upgrade path while supporting a much richer format. | |
spring_io/spring_io_11_1.txt | erver", "mysql", or "postgres"
` RabbitConnectionDetails ` | Containers named "rabbitmq"
` RedisConnectionDetails ` | Containers named "redis"
` ZipkinConnectionDetails ` | Containers named "openzipkin/zipkin".
### 10.3. Custom Images
Sometimes you may need to use your own version of an image to pro... | |
spring_io/bootfeaturesexternal1_273_0.txt | * ` B ` for bytes
* ` KB ` for kilobytes
* ` MB ` for megabytes
* ` GB ` for gigabytes
* ` TB ` for terabytes | |
spring_io/bootfeaturesexternal1_305_0.txt | If you define a set of configuration keys for your own components, we
recommend you group them in a POJO annotated with ` @ConfigurationProperties `
. Doing so will provide you with structured, type-safe object that you can
inject into your own beans. | |
spring_io/bootfeaturesexternal1_235_0.txt | acme:
map:
key1:
name: my name 1
description: my description 1
---
spring:
profiles: dev
acme:
map:
key1:
name: dev name 1
key2:
name: dev name 2
description: dev description 2 | |
spring_io/spring_io_3_19.txt | emoteAddress = remoteAddress;
}
public Security getSecurity() {
return this.security;
}
public static class Security {
@NotEmpty
private String username;
// getters/setters...
public String getUsername()... | |
spring_io/bootfeaturesexternal1_90_0.txt | ` spring.profiles ` can therefore contain a profile name (for example `
production ` ) or a profile expression. A profile expression allows for more
complicated profile logic to be expressed, for example ` production & (eu-
central | eu-west) ` . Check the [ reference guide
](https://docs.spring.io/spring/docs/5.1.19.R... | |
spring_io/bootfeaturesexternal_212_0.txt | * * * | |
spring_io/bootfeaturesexternal1_104_0.txt | We recommend that you don’t mix profile-specific YAML files and multiple YAML
documents. Stick to using only one of them. | |
spring_io/bootfeaturesexternal1_120_0.txt | private String username; | |
spring_io/spring_io_10_35.txt | ate;
import org.springframework.http.ResponseEntity;
import static org.assertj.core.api.Assertions.assertThat;
class MyTests {
private final TestRestTemplate template = new TestRestTemplate();
@Test
void testRequest() {
ResponseEntity<String> headers =... | |
spring_io/environmentvariables_15_0.txt | * Configurations of software like Apache, logging path etc. | |
spring_io/bootfeaturesexternal_191_0.txt | _@ConfigurationProperties(prefix="connection")_
_@Validated_
public class FooProperties { | |
spring_io/environmentvariables_5_0.txt | [ ](https://github.com/leeonscoding) [ ](https://hashnode.com/@leeonscoding) [
](http://www.youtube.com/@leeonscoding) [ ](https://www.linkedin.com/in/asfaq-
leeon-73760a106) [ ](/rss.xml) | |
spring_io/bootfeaturesexternal1_297_0.txt | Feature | ` @ConfigurationProperties ` | ` @Value `
---|---|--- | |
spring_io/bootfeaturesexternal_1_0.txt | * * * |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.