Spring Boot here. What are the possible values that one can specify for the management.trace.include property in application.properties, what are this property's default values, and where is all of this documented (pro tip: it's not!)?
For Spring Boot 2.1.0 it is:
org.springframework.boot.actuate.trace.http.Include
To see its values, see (enum constansts are processed by Spring - AUTHORIZATION_HEADER becomes authorization-header):
https://docs.spring.io/spring-boot/docs/2.1.0.RELEASE/api/org/springframework/boot/actuate/trace/http/Include.html#enum.constant.summary
Default value can be found here:
https://docs.spring.io/spring-boot/docs/2.1.0.RELEASE/reference/html/common-application-properties.html
Twas: org.springframework.boot.actuate.trace.TraceProperties.Include
Related
I have a Spring Boot application written in Kotlin and I would prefer to set the default of a #Value-annotated field like below:
#Value("\${service-clients.logging.exceptions:/}")
private var loggingExceptions: Array<String> = emptyArray()
Is there anything wrong with doing it this way? Most of the resources I found on the web recommend to set the default in the annotation itself. Is there any advantage of doing it that way?
I was wondering if we can supply a custom attribute (a key to be in application.properties file), I know for sure that -Dserver.port=8080 works, and overrides the property value, but server.port is a spring boot's expected property value.
How about something other than that, for example a jdbc connection string or service name? does -Ddb.service.name=dbservice work?
Yes, any property can be set via system property. You can use -D or -- notation. There are also a variety of property sources Spring Boot uses:
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
I see following in Spring Boot application.properties file. What is it doing here:
spring.datasource.password = ${DB_PASSWD:password}
It means try resolving DB_PASSWD property. If found, use it's value. If not, use the default provided value password. In short:
${property:defaultValue}
The property value is looked up from property sources registered in Spring context, see Environment.getProperty() and #PropertySource.
Can I use a propertie inside a application.properties?
sample:
myLevel=ERROR
logging.level.org.springframework=$myLevel
logging.level.org.apache.catalina=$myLevel
tks
You might use property placeholders:
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).
For your case:
myLevel=ERROR
logging.level.org.springframework=${myLevel}
logging.level.org.apache.catalina=${myLevel}
See also:
Spring Boot - Placeholders in properties
My Spring Boot application works on Spring Security 3.2.7.RELEASE.
Now, I'd like to update it to 4.0.2.RELEASE.
After hours of debug I have found that Spring Security 4.0.2.RELEASE uses defaultRolePrefix="ROLE_"
in
org.springframework.security.access.expression.SecurityExpressionRoot.hasAnyAuthorityName(String prefix, String... roles) method
In my application I use roles without this prefix and accordingly I get AccessDeniedException.
How to configure Spring Boot in order to use SecurityExpressionRoot.defaultRolePrefix="" ?
I found the solution how to fix it. I need to change hasRole to hasAuthority, for example:
#PreAuthorize("hasAuthority('PERMISSION_CREATE_NODE')")
In the other hand you can remove role prefix ass described here. In this cas you are free to use other annotations.