由于我尝试将我的应用程序连接到postgres数据库而不是h2,因此在启动jetty / spring启动服务器时出现以下错误:
2016-03-02 20:22:15.820 INFO 12954 --- [ restartedMain] com.bau.Application : Starting Application on bisupportsMBP4 with PID 12954 (/Users/mbennekrouf/workspace/bau-board/target/classes started by mbennekrouf in /Users/mbennekrouf/workspace/bau-board)
2016-03-02 20:22:15.822 DEBUG 12954 --- [ restartedMain] com.bau.Application : Running with Spring Boot v1.3.1.RELEASE, Spring v4.2.4.RELEASE
2016-03-02 20:22:15.822 INFO 12954 --- [ restartedMain] com.bau.Application : The following profiles are active: dev,fast
2016-03-02 20:22:18.430 DEBUG 12954 --- [ restartedMain] com.bau.config.AsyncConfiguration : Creating Async Task Executor
2016-03-02 20:22:19.052 WARN 12954 --- [ restartedMain] io.undertow.websockets.jsr : UT026009: XNIO worker was not set on WebSocketDeploymentInfo, the default worker will be used
2016-03-02 20:22:19.159 WARN 12954 --- [ restartedMain] io.undertow.websockets.jsr : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used
2016-03-02 20:22:19.586 INFO 12954 --- [ restartedMain] com.bau.config.WebConfigurer : Web application configuration, using profiles: [dev, fast]
2016-03-02 20:22:19.586 INFO 12954 --- [ restartedMain] com.bau.config.WebConfigurer : Web application fully configured
2016-03-02 20:22:19.661 DEBUG 12954
--- [ restartedMain] com.bau.config.DatabaseConfiguration : Configuring Datasource
2016-03-02 20:22:19.963 WARN 12954 --- [ bau-Executor-1] c.b.c.liquibase.AsyncSpringLiquibase : Starting Liquibase asynchronously, your database might not be ready at startup!
2016-03-02 20:22:19.965 DEBUG 12954 --- [ bau-Executor-1] c.b.c.liquibase.AsyncSpringLiquibase : Started Liquibase in 1 ms objc[12954]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/jre/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
2016-03-02 20:22:21.956 WARN 12954 --- [ restartedMain] o.h.c.e.AbstractEhcacheRegionFactory : HHH020003: Could not find a specific ehcache configuration for cache named [com.bau.domain.Task]; using defaults.
2016-03-02 20:22:22.024 WARN 12954 --- [ restartedMain] o.h.c.e.AbstractEhcacheRegionFactory : HHH020003: Could not find a specific ehcache configuration for cache named [com.bau.domain.PlannedTask]; using defaults.
2016-03-02 20:22:22.033 WARN 12954 --- [ restartedMain] o.h.c.e.AbstractEhcacheRegionFactory : HHH020003: Could not find a specific ehcache configuration for cache named [com.bau.domain.Project]; using defaults.
2016-03-02 20:22:22.043 WARN 12954 --- [ restartedMain] o.h.c.e.AbstractEhcacheRegionFactory : HHH020003: Could not find a specific ehcache configuration for cache named [com.bau.domain.Devis]; using defaults.
2016-03-02 20:22:22.049 WARN 12954 --- [ restartedMain] o.h.c.e.AbstractEhcacheRegionFactory : HHH020003: Could not find a specific ehcache configuration for cache named [com.bau.domain.Step]; using defaults.
2016-03-02 20:22:22.071 WARN 12954 --- [ restartedMain] o.h.c.e.AbstractEhcacheRegionFactory : HHH020003: Could not find a specific ehcache configuration for cache named [com.bau.domain.Collaborator]; using defaults.
2016-03-02 20:22:22.081 WARN 12954 --- [ restartedMain] o.h.c.e.AbstractEhcacheRegionFactory : HHH020003: Could not find a specific ehcache configuration for cache named [com.bau.domain.Task.plannedTasks]; using defaults.
2016-03-02 20:22:22.096 WARN 12954 --- [ restartedMain] o.h.c.e.AbstractEhcacheRegionFactory : HHH020003: Could not find a specific ehcache configuration for cache named [com.bau.domain.Step.tasks]; using defaults.
2016-03-02 20:22:22.101 WARN 12954 --- [ restartedMain] o.h.c.e.AbstractEhcacheRegionFactory : HHH020003: Could not find a specific ehcache configuration for cache named [com.bau.domain.Collaborator.plannedTasks]; using defaults.
2016-03-02 20:22:22.105 WARN 12954 --- [ restartedMain] o.h.c.e.AbstractEhcacheRegionFactory : HHH020003: Could not find a specific ehcache configuration for cache named [com.bau.domain.Project.steps]; using defaults.
2016-03-02 20:22:22.114 WARN 12954 --- [ restartedMain] o.h.c.e.AbstractEhcacheRegionFactory : HHH020003: Could not find a specific ehcache configuration for cache named [com.bau.domain.Project.deviss]; using defaults.
2016-03-02 20:22:22.312 INFO 12954 --- [ restartedMain] com.bau.Application : Running with Spring profile(s) : [dev, fast]
2016-03-02 20:22:22.504 WARN 12954 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt:
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 field: private org.springframework.security.core.userdetails.UserDetailsService com.bau.config.SecurityConfiguration.userDetailsService; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService': Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bau.repository.UserRepository com.bau.security.UserDetailsService.userRepository; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.bau.repository.UserRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
Dependency annotations: {@javax.inject.Inject()}
2016-03-02 20:22:22.528 ERROR 12954 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed
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 field: private org.springframework.security.core.userdetails.UserDetailsService com.bau.config.SecurityConfiguration.userDetailsService; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService': Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bau.repository.UserRepository com.bau.security.UserDetailsService.userRepository; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.bau.repository.UserRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
Dependency annotations: {@javax.inject.Inject()} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:764)
~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:357)
~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at com.bau.Application.main(Application.java:74) [classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[na:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[na:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[na:1.8.0_65] at java.lang.reflect.Method.invoke(Method.java:497)
~[na:1.8.0_65] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.3.1.RELEASE.jar:1.3.1.RELEASE] Caused by:
org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.security.core.userdetails.UserDetailsService com.bau.config.SecurityConfiguration.userDetailsService; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService': Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bau.repository.UserRepository com.bau.security.UserDetailsService.userRepository; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.bau.repository.UserRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
Dependency annotations: {@javax.inject.Inject()} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] ... 20 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService': Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bau.repository.UserRepository com.bau.security.UserDetailsService.userRepository; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.bau.repository.UserRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.inject.Inject()} at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] ... 22 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bau.repository.UserRepository com.bau.security.UserDetailsService.userRepository; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.bau.repository.UserRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.inject.Inject()} at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at
org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] ... 33 common frames omitted
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.bau.repository.UserRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.inject.Inject()} at
org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] ... 35 common frames omitted
2016-03-02 20:22:22.532 WARN 12954 --- [ restartedMain] o.s.boot.SpringApplication : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' is defined)
s
我可以提供conf文件。我不知道看看有什么有趣的东西。
答案 0 :(得分:1)
您使用开发和快速配置文件启动了应用,如跟踪中所示。
以下配置文件处于活动状态:dev,fast
当数据库不是H2时,快速配置文件用于禁用Liquibase(请参阅DatabaseConfiguration
类),因此尚未创建数据库模式。
if (env.acceptsProfiles(Constants.SPRING_PROFILE_FAST)) {
if ("org.h2.jdbcx.JdbcDataSource".equals(dataSourceProperties.getDriverClassName())) {
liquibase.setShouldRun(true);
log.warn("Using '{}' profile with H2 database in memory is not optimal, you should consider switching to" +
" MySQL or Postgresql to avoid rebuilding your database upon each start.", Constants.SPRING_PROFILE_FAST);
} else {
liquibase.setShouldRun(false);
}
}
所以你要么只使用devg配置文件和Postgresql,要么使用带有H2和prod配置文件的dev配置文件和Postgresql,这可能是你在生成应用程序时选择的。
如果您希望始终在开发中使用Postgresql,则需要编辑.yo-rc.json
文件以更改devDatabaseType
并使用应用目录中的yo jhipster
重新生成。