2015-05-18 3 views
1

При запуске приложения для запуска Springboot у меня есть следующее исключение. Я не нашел, где проблема, если кто-то есть идея ... спасибо по заранееNotReadablePropertyException при запуске tomcat с Spring Boot

2015-05-18 14:50:49,313 DEBUG c.q.q.Application:50 - Running with Spring Boot v1.2.3.RELEASE, Spring v4.1.6.RELEASE 
2015-05-18 14:50:51,848 DEBUG o.j.logging:33 - Logging Provider: org.jboss.logging.Slf4jLoggerProvider 
2015-05-18 14:50:51,991 DEBUG c.q.q.c.AsyncConfiguration:36 - Creating Async Task Executor 
2015-05-18 14:50:52,126 INFO c.q.q.Application:60 - Running with Spring profile(s) : [dev] 
2015-05-18 14:50:52,752 DEBUG c.q.q.c.MetricsConfiguration:71 - Registring JVM gauges 
2015-05-18 14:50:54,870 ERROR o.s.b.c.e.t.TomcatStarter:62 - Error starting Tomcat context: org.springframework.beans.factory.BeanCreationException 
2015-05-18 14:50:54,914 WARN o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext:487 - Exception encountered during context initialization - cancelling refresh attempt 
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) [spring-boot-1.2.3.RELEASE.jar:1.2.3.RELEASE] 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE] 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) [spring-boot-1.2.3.RELEASE.jar:1.2.3.RELEASE] 
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) [spring-boot-1.2.3.RELEASE.jar:1.2.3.RELEASE] 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) [spring-boot-1.2.3.RELEASE.jar:1.2.3.RELEASE] 
    at com.qwam.qes.Application.main(Application.java:84) [classes/:na] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25] 
    at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25] 
    at org.springframework.boot.maven.RunMojo$LaunchRunner.run(RunMojo.java:418) [spring-boot-maven-plugin-1.2.3.RELEASE.jar:1.2.3.RELEASE] 
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25] 
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat 
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:98) ~[spring-boot-1.2.3.RELEASE.jar:1.2.3.RELEASE] 
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:75) ~[spring-boot-1.2.3.RELEASE.jar:1.2.3.RELEASE] 
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:378) ~[spring-boot-1.2.3.RELEASE.jar:1.2.3.RELEASE] 
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:155) ~[spring-boot-1.2.3.RELEASE.jar:1.2.3.RELEASE] 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:157) [spring-boot-1.2.3.RELEASE.jar:1.2.3.RELEASE] 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130) [spring-boot-1.2.3.RELEASE.jar:1.2.3.RELEASE] 
    ... 11 common frames omitted 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor,java.util.List) throws java.lang.Exception; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter.setAuthenticationConfiguration(org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration.setGlobalAuthenticationConfigurers(java.util.List) throws java.lang.Exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springBootAuthenticationConfigurerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/security/AuthenticationManagerConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.boot.autoconfigure.security.SecurityProperties]: : Error creating bean with name 'securityProperties': Could not bind properties to [unknown] (target=security, ignoreInvalidFields=false, ignoreUnknownFields=false, ignoreNestedProperties=false); nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'token[key]' of bean class [org.springframework.boot.autoconfigure.security.SecurityProperties]: Cannot access indexed value in property referenced in indexed property path 'token[key]'; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'token[key]' of bean class [org.springframework.boot.autoconfigure.security.SecurityProperties]: Bean property 'token[key]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityProperties': Could not bind properties to [unknown] (target=security, ignoreInvalidFields=false, ignoreUnknownFields=false, ignoreNestedProperties=false); nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'token[key]' of bean class [org.springframework.boot.autoconfigure.security.SecurityProperties]: Cannot access indexed value in property referenced in indexed property path 'token[key]'; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'token[key]' of bean class [org.springframework.boot.autoconfigure.security.SecurityProperties]: Bean property 'token[key]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? 

это мой класс приложения:

@ComponentScan (basePackages = { "com.test" }) 
@EnableAutoConfiguration(exclude = {MetricFilterAutoConfiguration.class, MetricRepositoryAutoConfiguration.class}) 
@Domain(basePackages = { "com.test.domain" }) 
public class Application { 

    private final Logger log = LoggerFactory.getLogger(Application.class); 

    @Inject 
    private Environment env; 

    @PostConstruct 
    public void initApplication() throws IOException { 
     if (env.getActiveProfiles().length == 0) { 
      log.warn("No Spring profile configured, running with default configuration"); 
     } else { 
      log.info("Running with Spring profile(s) : {}", Arrays.toString(env.getActiveProfiles())); 
     } 
    } 

    public static void main(String[] args) { 
     SpringApplication app = new SpringApplication(Application.class); 
     app.setShowBanner(false); 

     SimpleCommandLinePropertySource source = new SimpleCommandLinePropertySource(args); 

     // Check if the selected profile has been set as argument. 
     // if not the development profile will be added 
     addDefaultProfile(app, source); 

    } 

     /** 
    * Set a default profile if it has not been set 
    * 
    * @param app 
    * @param source 
    */ 
    private static void addDefaultProfile(SpringApplication app, SimpleCommandLinePropertySource source) { 
     if (!source.containsProperty("spring.profiles.active")) { 
      app.setAdditionalProfiles(Constants.SPRING_PROFILE_DEVELOPMENT); 
     } 
    } 

    /** 
    * 
    * @return 
    */ 
    @Bean 
    public HttpMessageConverter<String> responseBodyConverter() { 
     return new StringHttpMessageConverter(Charset.forName("UTF-8")); 
    } 

    @Bean 
    public Filter characterEncodingFilter() { 
     CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); 
     characterEncodingFilter.setEncoding("UTF-8"); 
     characterEncodingFilter.setForceEncoding(true); 
     return characterEncodingFilter; 
    } 


    /** 
    * 
    * @return 
    */ 
    @Bean 
    public BeanNameAutoProxyCreator lazyInitAutoProxyCreator() { 
     BeanNameAutoProxyCreator autoProxyCreator = new BeanNameAutoProxyCreator(); 
     TargetSourceCreator[] targetSourceCreators = {lazyInitTargetSourceCreator()}; 
     autoProxyCreator.setCustomTargetSourceCreators(targetSourceCreators); 
     return autoProxyCreator; 
    } 

    @Bean 
    public LazyInitTargetSourceCreator lazyInitTargetSourceCreator() { 
     return new LazyInitTargetSourceCreator(); 
    } 
} 
+0

Можете ли вы показать нам стартовый класс «Применение»? – MChaker

ответ

1

Попробуйте добавить @Configuration аннотацию к вашему Application класса

@Configuration 
@ComponentScan (basePackages = { "com.test" }) 
@EnableAutoConfiguration(exclude = {MetricFilterAutoConfiguration.class, MetricRepositoryAutoConfiguration.class}) 
@Domain(basePackages = { "com.test.domain" }) 
public class Application {   
     //some code 
} 
+0

спасибо, что это работает! – lbu

Смежные вопросы