当前位置: 首页 > 知识库问答 >
问题:

生成错误:无法实例化接口org.springframework.Boot.springapplicationrunlistener Spring Boot

印成天
2023-03-14
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: 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 

欢迎(org.springframework.ui.model)到{[/],methods=[GET]}:已经映射了“page controller”bean方法public java.lang.string com.jeeniso.controllers.PageController.PlainPage()。2018-02-18 14:28:27.667信息12088---[restartedMain]J.LocalContainerEntityManagerFactoryBean:关闭持久性单元“default”的JPA EntityManagerFactory----[restartedMain]O.Apache.catalina.core.StandardService:停止服务Tomcat 2018-02-18 14:28:27.691信息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

共有1个答案

薛弘厚
2023-03-14

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

UserController.Welcome(...)映射到Get/

这是完全相同的映射

PageController.PlainPage()映射到。

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

例如。

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

将具有/MyController/Get映射

 类似资料:
  • 环境:Spring Boot 2.2.6 启动程序:spring-boot-starter-data-jpa,*-thymeleaf,*-web,*-Tomcat,*-test 其他依赖项:mariadb-java-client 2.6.0,spring-boot-devtools(管理),lombok(管理) DB mariadb:10.4 Hibernate方言:mariadb103 使用内部

  • 问题内容: 扩展初始化接口时提出的问题?),我们在实例化接口的同时用实现的类对其进行初始化。 我的问题是,为什么首先要使用Interface实例化它?为什么我不能直接用实现的类实例化它?例如。: Doc是接口,而SimpleDoc正在实现它。SimpleDoc有什么问题?mydoc = new SimpleDoc(); 哪里会失败? 问题答案: 通常,最好的方法是依赖系统中的抽象类型(接口或抽象类

  • 正如我在标题中提到的,我的本地计算机上使用Gradle的项目开始抛出以下错误: 我不知道怎么解决它。 到目前为止我所尝试的; > 删除并安装intellij 以新的回购协议进行尝试 删除gradle缓存 添加了log4j和slf4j库,我在SO上找到了一个解决方案。 如何修复异常:无法实例化SLF4J LoggerFactory? 未能实例化SLF4J LoggerFactory IntelliJ

  • 在将maven项目导入到Eclipse Luna之后,在修改方法后保存时,弹出窗口中会显示以下错误: 无法初始化模块TreeWalker-无法实例化JUnitTestCase

  • 我在跟随一位导游http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/对于GCM。 目前,我被困在接收通知的部分。有时,当我运行代码时,它会因以下错误而崩溃: 7.517:E/AndroidRuntime(8601):致命异常:mai

  • 问题内容: 我遇到以下错误,根本原因是 模块’ngRoute’不可用 未捕获的错误:[$ injector:modulerr]由于以下原因,无法实例化模块Amail: 错误:[$ injector:modulerr]由于以下原因,无法实例化模块ngRoute: 错误:[$ injector:nomod]模块’ngRoute’不可用!您可能拼错了模块名称,或者忘记了加载它。如果注册模块,请确保将依赖