当我用spring boot启动apache tomcat时,我的组件扫描和一些其他注释出现以下异常:
@ComponentScan(basePackages =
{"com.ce.resources","com.ce.services","com.ce.repository"})
@EnableJpaRepositories("com.ce.repository")
@EntityScan("healthchecker")
@SpringBootApplication
2018-10-01 14:22:21.000 WARN 14044 --- [ost-startStop-1] ConfigServletWebServerApplicationContext:上下文初始化期间遇到异常-取消刷新尝试:org.springframework.beans.factory.UnsatisfiedDependencyException:创建bean时出错在文件[D:\ appache \ apache-tomcat-8.5.34 \ webapps \ ng-ols-platformservice \ WEB-INF \ classes \ com \ ce \ resources \ UserprofileResource.class]中定义的名称“ userprofileResource”:表示不满意的依赖性通过构造函数参数0;嵌套的异常是org.springframework.beans.factory.UnsatisfiedDependencyException:创建文件[D:\ appache \ apache-tomcat-8.5.34 \ webapps \ ng-ols-platformservice \ WEB-INF \ [class \ com \ ce \ services \ UserProfileService.class]:通过构造函数参数0表示的不满意依赖关系;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名称为'userProfileRespository'的bean时出错:调用init方法失败;嵌套异常为java.lang.IllegalArgumentException:不是托管类型:com.ce.entity.UserProfile类 2018-10-01 14:22:21.000 INFO 14044-[ost-startStop-1] j.LocalContainerEntityManagerFactoryBean:为持久性单元'default'关闭JPA EntityManagerFactory 2018-10-01 14:22:21.010 INFO 14044-[ost-startStop-1] com.zaxxer.hikari.HikariDataSource:HikariPool-1-已启动关机... 2018-10-01 14:22:21.029信息14044-[ost-startStop-1] com.zaxxer.hikari.HikariDataSource:HikariPool-1-关闭已完成。 2018-10-01 14:22:21.051 INFO 14044-[ost-startStop-1] ConditionEvaluationReportLoggingListener:
启动ApplicationContext时出错。要显示条件报告,请在启用“调试”的情况下重新运行您的应用程序。 2018-10-01 14:22:21.080错误14044 --- [ost-startStop-1] o.s.boot.SpringApplication:应用程序运行失败
org.springframework.beans.factory.UnsatisfiedDependencyException:在文件[D:\ appache \ apache-tomcat-8.5.34 \ webapps \ ng-ols-platformservice \ WEB-INF \中定义的名称为'userprofileResource'的bean创建时出错类:\ com \ ce \ resources \ UserprofileResource.class]:通过构造函数参数0表示的不满足的依赖关系;嵌套的异常是org.springframework.beans.factory.UnsatisfiedDependencyException:创建文件[D:\ appache \ apache-tomcat-8.5.34 \ webapps \ ng-ols-platformservice \ WEB-INF \ [class \ com \ ce \ services \ UserProfileService.class]:通过构造函数参数0表示的不满意依赖关系;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名称为'userProfileRespository'的bean时出错:调用init方法失败;嵌套异常为java.lang.IllegalArgumentException:不是托管类型:com.ce.entity.UserProfile类 在org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] 在org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1267)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1124)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.lambda $ doGetBean $ 0(AbstractBeanFactory.java:317)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] 在org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)〜[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)〜[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE] 在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)〜[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] 在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780)〜[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] 在org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412)〜[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:333)〜[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] 在org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:157)[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] 在org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:137)上[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] 在org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:91)[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] 在org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:172)[spring-web-5.0.9.RELEASE.jar:5.0.9.RELEASE] 在org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5245)[catalina.jar:8.5.34] 在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)[catalina.jar:8.5.34] 在org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)[catalina.jar:8.5.34] 在org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)[catalina.jar:8.5.34] 在org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)[catalina.jar:8.5.34] 在org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)[catalina.jar:8.5.34] 在org.apache.catalina.startup.HostConfig $ DeployWar.run(HostConfig.java:1857)[catalina.jar:8.5.34] 在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)[na:1.8.0_91] 在java.util.concurrent.FutureTask.run(FutureTask.java:266)[na:1.8.0_91] 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[na:1.8.0_91] 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)[na:1.8.0_91]
答案 0 :(得分:0)
启用jpa存储库以使spring-boot知道在哪里可以找到存储库。
@EnableJpaRepositories("com.ce.repository")