老师,我的logback在访问地址后出现了下面的问题
来源:3-2 logback的配置
springbaby
2020-03-13
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘areaController’ defined in file [D:\Eclipse\Eclipse for Java EE\eclipse\eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\o2o\WEB-INF\classes\com\imooc\o2o\web\superadmin\AreaController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘org.slf4j.Logger’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘org.slf4j.Logger’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2回答
-
翔仔
2020-03-13
同学是不是spring版本有问题。。不知道为什么logger实现类没有被注入,不过可以这样写,在spring-dao.xml里面,第一个bean标签添加
<bean id="logger" scope="prototype" class="org.slf4j.LoggerFactory" factory-method="getLogger"> <constructor-arg name="name" value="logger" /> </bean>
使用的时候,就可以在类里定义一个成员变量
@Autowired private Logger logger;
然后直接用logger。
012020-03-14 -
翔仔
2020-03-13
同学好,感觉是缺少jar?
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic --> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.2.3</version> </dependency>
引入后,update maven project试试,如果还是不行,就引入
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.25</version> </dependency>
试试
022020-03-15
相似问题