当 Java 应用程序运行时,如何避免 Eclipse 将测试类文件加载到类路径中? [英] How avoid Eclipse load test-class file in to classpath when Java app run?

查看:32
本文介绍了当 Java 应用程序运行时,如何避免 Eclipse 将测试类文件加载到类路径中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

解决方案

正如@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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆