"Spring Boot Unit Test忽略了logging.level"是说在Spring Boot的单元测试中,日志记录级别将被忽略。
"Spring Boot Unit Test忽略了logging.level"是说在Spring Boot的单元测试中,日志记录级别将被忽略。
我的某个maven模块在运行测试时忽略了我的日志级别。
在src/test/resources
中我有一个application.properties
文件:
app.name=bbsng-import-backend app.description=Import Backend Module for Application spring.profiles.active=test # LOGGING logging.level.root=error logging.level.org.springframework.core =fatal logging.level.org.springframework.beans=fatal logging.level.org.springframework.context=fatal logging.level.org.springframework.transaction=error logging.level.org.springframework.test=error logging.level.org.springframework.web=error logging.level.org.hibernate=ERROR
我还尝试过application-test.properties
。
我的应用程序记录了大量日志,尤其是在加载上下文时。我尝试过logback.xml
,logback-test.xml
和logback-spring.xml
,但是没有帮助。
我的pom文件:
at.company.bbsng bbsng-import 0.1.0-SNAPSHOT bbsng-import-backend bbsng-import-backend at.company.bbsng.dataimport.ApplicationImportBackend at.company.bbsng bbsng-app-domain test org.springframework.boot spring-boot-starter-batch org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-starter-data-jpa test ... ... ... ... org.springframework.boot spring-boot-maven-plugin ${org.springframework.boot-version} repackage
一个简单的测试类:
@ContextConfiguration(classes = { ApplicationImportBackend.class }) @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles({ "test" }) public class BatchJobConfigurationTests { @Autowired private JobLauncher jobLauncher; @Test public void testSimpleProperties() throws Exception { assertNotNull(jobLauncher); } }
应用程序记录处于DEBUG模式。
是的,application.properties
将被加载。我已经尝试通过错误配置来破坏应用程序。
感谢任何提示。
admin 更改状态以发布 2023年5月23日