当 Java 应用程序运行时,如何避免 Eclipse 将测试类文件加载到类路径中? [英] How avoid Eclipse load test-class file in to classpath when Java app run?
问题描述
我正在使用
正如@torsten-crass 所指出的,请验证您的 Classpath
中是否勾选了 Exclude test code
在 Eclipse 中运行配置选项卡.
这是截图.
I am using STS to develop a large Spring Boot based application. We have multiple maven projects and a parent project to include them all. Each project has own testing code and config files.
When I run the Spring Boot application in the main entry class. The test-classes folder of the depended projects will be loaded into the app running classpath, that causes some conflict of spring bean definition. I have to config every project removing [src/test/java and src/test/resources] from the 'source folders on build path'.
The whole project structure is like below:
app-parent
sub-app-1
sub-app-2
sub-app-3
main-app [running from this project]
main-app project has dependencies on the sub-app-1 ~ 3.
Is there any way to let STS (Eclipse) run a Java App excluding the test-classes folder from classpath? I really do want the testing code under source folder but not have them when the App run.
Besides, I tried open the [run configuration], but it can only add more file to the classpath.
As pointed out by @torsten-crass, verify that Exclude test code
is ticked in your Classpath
tab of Run configurations in Eclipse.
Here is the screenshot.
这篇关于当 Java 应用程序运行时,如何避免 Eclipse 将测试类文件加载到类路径中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!