-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Description
Hello,
I have the following problem and I believe it might be a bug.
I have a multi-module application
core
- working perfectlyrest-api
- working perfectly (depends oncore
)web-admin
- I'm currently creating this module (depends oncore
)
@SpringBootConfiguration
@Import({
CoreBootstrap.class, // config from module core
WebConfiguration.class,
WebSecurityConfiguration.class,
})
@PropertySource("classpath:application-web-admin.properties")
public class WebAdminApplication
{
public static void main(final String[] args)
{
new SpringApplicationBuilder(WebAdminApplication.class)
.registerShutdownHook(true)
.bannerMode(Banner.Mode.OFF)
.web(WebApplicationType.SERVLET)
.run(args);
}
}
@Configuration
@EnableWebSecurity
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter
{
...
@Configuration
@Import({
ForwardedHeadersConfiguration.class, // enables ForwardedHeaderFilter
})
@EnableWebMvc
public class WebConfiguration implements WebMvcConfigurer
{
...
File application-web-admin.properties
server.servlet.context-path=/
spring.jpa.open-in-view=false
spring.mvc.throw-exception-if-no-handler-found=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
spring.security.filter.order=10
spring.thymeleaf.enabled=true
spring.mvc.locale-resolver=FIXED
spring.mvc.locale=en
#spring.resources.cache.period=1s
#spring.mvc.contentnegotiation.favor-parameter=false
#spring.mvc.contentnegotiation.favor-path-extension=false
management.endpoint.health.showDetails=WHEN_AUTHORIZED
management.endpoint.health.roles=ACTUATOR
Now - I've been struggling to figure out, why my static resources are returning 404 - and I believe I might have found the reason thanks to this SO answer, so I've removed the @EnableWebMvc
annotation and suddenly this:
23:19:47.623 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [******]
23:19:53.453 [restartedMain ] INFO com.cogvio.WebAdminApplication: Starting WebAdminApplication
23:19:53.454 [restartedMain ] DEBUG com.cogvio.WebAdminApplication: Running with Spring Boot v2.0.0.RC2, Spring v5.0.4.RELEASE
23:19:57.191 [localhost-start] INFO org.springframework.web.context.ContextLoader: Root WebApplicationContext: initialization completed in 3684 ms
23:31:27.431 [restartedMain ] WARN ationConfigServletWebServerApplicationContext: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Unsatisfied dependency expressed through method 'setFilterChainProxySecurityConfigurer' parameter 1; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.cogvio.config.WebSecurityConfiguration': Unsatisfied dependency expressed through method 'setContentNegotationStrategy' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.resources-org.springframework.boot.autoconfigure.web.ResourceProperties': Could not bind properties to 'ResourceProperties' : prefix=spring.resources, ignoreInvalidFields=false, ignoreUnknownFields=false; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.resources.cache.period' to java.time.Duration
23:31:28.634 [restartedMain ] ERROR o.s.b.d.LoggingFailureAnalysisReporter:
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'spring.resources.cache.period' to java.time.Duration:
Property: spring.resources.cache.period
Value: 0
Origin: "spring.resources.cache.period" from property source "refresh"
Reason: No converter found capable of converting from type [java.lang.String] to type [@org.springframework.boot.convert.DurationUnit java.time.Duration]
Action:
Update your application's configuration
I've tried to step-debug it, but there is multiple conversion services, some of them are static and the binding is happening behind 30+ layers of method calls.
If I uncomment this, nothing changes - the error message stays the same (the Value: 0
doesn't change)
spring.resources.cache.period=1s
I believe the value comes from here
If I remove this from my pom.xml
, it starts working
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
After I've "fixed" all this, I've decided that I want to change those settings, so I've set
spring.resources.cache.cachecontrol.maxAge=P365D
but - the same problem
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'spring.resources.cache.cachecontrol.max-age' to java.time.Duration:
Property: spring.resources.cache.cachecontrol.maxage
Value: P365D
Origin: "spring.resources.cache.cachecontrol.maxAge" from property source "class path resource [application-web-admin.properties]"
Reason: No converter found capable of converting from type [java.lang.String] to type [@org.springframework.boot.convert.DurationUnit java.time.Duration]
Action:
Update your application's configuration
Which leads me to think, that Spring Boot contains properties that you simply cannot configure, without creating a custom converter.