报错信息如下:

01-17 09:18:38.158 WARN  [o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'compljsController': Unsatisfied dependency expressed through field 'compljsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'compljsServiceImpl': Unsatisfied dependency expressed through field 'compljsMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.ljs.modules.compljssive.mapper.CompljsMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
01-17 09:18:38.162 WARN  [o.s.beans.factory.support.DisposableBeanAdapter] - Destroy method 'close' on bean with name 'eurekaRegistration' threw an exception: org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
01-17 09:18:38.189 INFO  [org.apache.catalina.core.StandardService] - Stopping service [Tomcat]
01-17 09:18:38.264 WARN  [org.apache.catalina.loader.WebappClassLoaderBase] - The web application [ROOT] appears to have started a thread named [RxIoScheduler-1 (Evictor)] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.misc.Unsafe.park(Native Method)
 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 java.lang.Thread.run(Thread.java:748)
01-17 09:18:38.280 INFO  [o.s.b.a.l.ConditionEvaluationReportLoggingListener] - 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
01-17 09:18:38.633 ERROR [o.s.b.diagnostics.LoggingFailureAnalysisReporter] - 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field compljsMapper in com.ljs.modules.ljssive.service.impl.CompljsServiceImpl required a bean of type 'com.ljs.modules.comljs.mapper.CompljsMapper' that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.ljs.modules.ljssive.mapper.CompljsMapper' in your configuration.

Disconnected from the target VM, address: '127.0.0.1:52000', transport: 'socket'

Process finished with exit code 1

原因解释:

网上也有资料说是循环调用,举个例子,A类中引入B类,B类中引入A类,被锁造成。不排除这种原因。

但是在动手排除这稍微复杂的原因之前,建议先看看启动类main方法上边的包扫描路径对不对。

如下:

@MapperScan({"com.ljs.**.mapper", "com.ljs.**.dao"})
@EnableAsync
@EnableDiscoveryClient
@EnableEurekaClient
@EnableFeignClients
@EnableTransactionManagement
@EnableScheduling
@EnableCaching
@ComponentScan(value = {"com.ljs"})
@Slf4j
@EnableHystrix
@EnableHystrixDashboard
@SpringBootApplication
public class MljsApplication {
    public static void main(String[] args) {
        SpringApplication.run(MljsApplication.class, args);
    }
}

我的项目启动报错原因在于,@MapperScan({“com.ljs.**.mapper”, “com.ljs.**.dao”})这个包扫描路径问题,现在写法是正确的。

通过翻看Git历史,发现并没有修改记录。后来想到,可能是由于写代码时,误触快捷键,idea将启动类的包扫描路径做了自动修改。导致模块扫描不到类,无法启动。

 


版权声明:本文为weixin_43421537原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_43421537/article/details/104014383