构建错误:无法实例化接口org.springframework.boot.SpringApplicationRunListener Spring Boot

时间:2018-02-18 10:38:41

标签: java spring spring-boot

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.4.1.RELEASE)

2018-02-18 14:28:21.922  INFO 12088 --- [  restartedMain] 
com.jeeniso.BusinessDashboard            : Starting BusinessDashboard on HP-Pavilion with PID 12088 (E:\education\ENISo\JuniorEntreprise\plateforme\BusinessDashboard\target\classes started by chiheb in E:\education\ENISo\JuniorEntreprise\plateforme\BusinessDashboard)
2018-02-18 14:28:21.926  INFO 12088 --- [  restartedMain] com.jeeniso.BusinessDashboard            : No active profile set, falling back to default profiles: default
2018-02-18 14:28:22.335  INFO 12088 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@25410cc2: startup date [Sun Feb 18 14:28:22 GMT+01:00 2018]; root of context hierarchy
2018-02-18 14:28:23.834  INFO 12088 --- [  restartedMain] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'templateEngine' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=thymeleafWebMvcConfig; factoryMethodName=templateEngine; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/jeeniso/configurations/ThymeleafWebMvcConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration; factoryMethodName=templateEngine; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration.class]]
2018-02-18 14:28:24.176  INFO 12088 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$ceaf63ba] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-02-18 14:28:24.642  INFO 12088 --- [  restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2018-02-18 14:28:24.650  INFO 12088 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service Tomcat
2018-02-18 14:28:24.651  INFO 12088 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.5
2018-02-18 14:28:24.738  INFO 12088 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-02-18 14:28:24.738  INFO 12088 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2408 ms
2018-02-18 14:28:24.972  INFO 12088 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-02-18 14:28:24.972  INFO 12088 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-02-18 14:28:24.972  INFO 12088 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-02-18 14:28:24.972  INFO 12088 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-02-18 14:28:24.973  INFO 12088 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-02-18 14:28:24.974  INFO 12088 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'resourceUrlEncodingFilter' to: [/*]
2018-02-18 14:28:24.974  INFO 12088 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2018-02-18 14:28:25.250  INFO 12088 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-02-18 14:28:25.262  INFO 12088 --- [  restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-02-18 14:28:25.354  INFO 12088 --- [  restartedMain] org.hibernate.Version                    : HHH000412: Hibernate Core {5.0.11.Final}
2018-02-18 14:28:25.355  INFO 12088 --- [  restartedMain] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2018-02-18 14:28:25.356  INFO 12088 --- [  restartedMain] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2018-02-18 14:28:25.393  INFO 12088 --- [  restartedMain] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-02-18 14:28:25.926  INFO 12088 --- [  restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect
2018-02-18 14:28:26.334  INFO 12088 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000227: Running hbm2ddl schema export
Hibernate: alter table user_role drop constraint FKa68196081fvovjhkek5m97n3y
2018-02-18 14:28:26.338 ERROR 12088 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000389: Unsuccessful: alter table user_role drop constraint FKa68196081fvovjhkek5m97n3y
2018-02-18 14:28:26.338 ERROR 12088 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport  : user lacks privilege or object not found: PUBLIC.USER_ROLE
Hibernate: alter table user_role drop constraint FK859n2jvi8ivhui0rl0esws6o
2018-02-18 14:28:26.338 ERROR 12088 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000389: Unsuccessful: alter table user_role drop constraint FK859n2jvi8ivhui0rl0esws6o
2018-02-18 14:28:26.338 ERROR 12088 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport  : user lacks privilege or object not found: PUBLIC.USER_ROLE
Hibernate: drop table role if exists
Hibernate: drop table user if exists
Hibernate: drop table user_role if exists
Hibernate: create table role (id bigint generated by default as identity (start with 1), name varchar(255), primary key (id))
Hibernate: create table user (id bigint generated by default as identity (start with 1), password varchar(255), username varchar(255), primary key (id))
Hibernate: create table user_role (user_id bigint not null, role_id bigint not null, primary key (user_id, role_id))
Hibernate: alter table user_role add constraint FKa68196081fvovjhkek5m97n3y 
foreign key (role_id) references role
Hibernate: alter table user_role add constraint FK859n2jvi8ivhui0rl0esws6o 
 foreign key (user_id) references user
 2018-02-18 14:28:26.343  INFO 12088 --- [  restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000230: Schema export complete
2018-02-18 14:28:26.385  INFO 12088 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-02-18 14:28:27.088  WARN 12088 --- [  restartedMain] org.thymeleaf.templatemode.TemplateMode  : [THYMELEAF][restartedMain] Template Mode 'HTML5' is deprecated. Using Template Mode 'HTML' instead.
2018-02-18 14:28:27.511  INFO 12088 --- [  restartedMain] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@44825d85, org.springframework.security.web.context.SecurityContextPersistenceFilter@7ccf6021, org.springframework.security.web.header.HeaderWriterFilter@b42d62f, org.springframework.security.web.csrf.CsrfFilter@32a5c279, org.springframework.security.web.authentication.logout.LogoutFilter@33f48d12, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@36fc0a7e, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@6299fd96, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@97a4947, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@682244c3, org.springframework.security.web.session.SessionManagementFilter@59c278f9, org.springframework.security.web.access.ExceptionTranslationFilter@4940954c, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@a831613]
2018-02-18 14:28:27.602  INFO 12088 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@25410cc2: startup date [Sun Feb 18 14:28:22 GMT+01:00 2018]; root of context hierarchy
2018-02-18 14:28:27.661  INFO 12088 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/calendar],methods=[GET]}" onto public java.lang.String com.jeeniso.controllers.PageController.calendar()
2018-02-18 14:28:27.662  INFO 12088 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/pricing-tables],methods=[GET]}" onto public java.lang.String com.jeeniso.controllers.PageController.pricingTables()
2018-02-18 14:28:27.662  INFO 12088 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto public java.lang.String com.jeeniso.controllers.PageController.plainPage()
2018-02-18 14:28:27.665  INFO 12088 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/registration],methods=[POST]}" onto public java.lang.String com.jeeniso.controllers.UserController.registration(com.jeeniso.models.User,org.springframework.validation.BindingResult,org.springframework.ui.Model)
2018-02-18 14:28:27.666  INFO 12088 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/registration],methods=[GET]}" onto public java.lang.String com.jeeniso.controllers.UserController.registration(org.springframework.ui.Model)
2018-02-18 14:28:27.666  WARN 12088 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'userController' method 

public java.lang.String com.jeeniso.controllers.UserController.welcome(org.springframework.ui.Model) to {[/],methods = [GET]}:已经有'pageController'bean方法 public java.lang.String com.jeeniso.controllers.PageController.plainPage()映射。     2018-02-18 14:28:27.667 INFO 12088 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean:关闭持久性单元'default'的JPA EntityManagerFactory     2018-02-18 14:28:27.677 INFO 12088 --- [restartedMain] o.apache.catalina.core.StandardService:停止服务Tomcat     2018-02-18 14:28:27.691 INFO 12088 --- [restartedMain] utoConfigurationReportLoggingInitializer:

 Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-02-18 14:28:27.699 ERROR 12088 --- [  restartedMain] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'userController' method
public java.lang.String 
com.jeeniso.controllers.UserController.welcome(org.springframework.ui.Model)
to {[/],methods=[GET]}: There is already 'pageController' bean method
public java.lang.String com.jeeniso.controllers.PageController.plainPage() 
mapped.
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.ini
 tializeBean(AbstractAutowireCapableBeanFactory.java:1583) ~[spring-beans-
 4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:751) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at com.jeeniso.BusinessDashboard.main(BusinessDashboard.java:19) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_101]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.4.1.RELEASE.jar:1.4.1.RELEASE]
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'userController' method 
public java.lang.String com.jeeniso.controllers.UserController.welcome(org.springframework.ui.Model)
to {[/],methods=[GET]}: There is already 'pageController' bean method

public java.lang.String com.jeeniso.controllers.PageController.plainPage() mapped.
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.assertUniqueMethodMapping(AbstractHandlerMethodMapping.java:576) ~[spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.register(AbstractHandlerMethodMapping.java:540) ~[spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod(AbstractHandlerMethodMapping.java:264) ~[spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:250) ~[spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:214) ~[spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:184) ~[spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:128) ~[spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1642) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
... 21 common frames omitted


Process finished with exit code 0

2 个答案:

答案 0 :(得分:2)

如错误消息所示,您的第二个问题是您有两个控制器都映射到同一个端点。

UserController.welcome(...)已映射到GET /

这是完全相同的映射

PageController.plainPage()映射到。

您应该向控制器添加RequestMapping注释以确保它们不同,这也可以在方法本身上完成。

E.g。

@RestController
@RequestMapping("/myController")
public class myController(){
   @GetMapping("/")
   public String get(){
      return "hello world";
   }
}

会有GET

/myController/映射

答案 1 :(得分:-2)

Make sure you have few spring boot annotation in your main class :

@SpringBootApplication  @EnableAutoConfiguration