Java 如何防止eclipse在Tomcat上部署测试类?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9818804/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to prevent eclipse from deploying test classes on Tomcat?
提问by Ralph
I have a Maven project, containing the typical folders src/main/java
and src/test/java
and I am using Eclipse 3.7 with m2e 1.0.and Maven Integration for WTP 1.4.0 . Eclipse is used during development to deploy the application on an server (Tomcat or Glassfish), but it deploys the test classes from src/test/java
folder too.
我有一个 Maven 项目,其中包含典型的文件夹src/main/java
,src/test/java
并且我使用 Eclipse 3.7 和 m2e 1.0.and Maven Integration for WTP 1.4.0 。Eclipse 在开发过程中用于在服务器(Tomcat 或 Glassfish)上部署应用程序,但它也从src/test/java
文件夹部署测试类。
I do not want the test classes deployed, so how can I "exclude" that directory from eclipse-tomcat deployment?
我不想部署测试类,那么如何从 eclipse-tomcat 部署中“排除”该目录?
采纳答案by Ralph
It is configurable in Eclipse how to handle and deploy the different folders, somehow the Eclipse plugin M2Eclipse should configure Eclipse right, it seams that the configuration sometimes is done and sometimes not.
它可以在 Eclipse 中配置如何处理和部署不同的文件夹,不知何故 Eclipse 插件 M2Eclipse 应该正确配置 Eclipse,它看起来配置有时完成有时不完成。
So one has to check this two settings:
所以必须检查这两个设置:
Project Properties\Java Build Path(Tab)Source : Outputfolder for
<PROJECT>/src/test/java
as well as<PROJECT>/src/test/resources
must be<PROJECT>/target/test-classes
Project Properties\Deployment Assembly : There must be NO entry for
<PROJECT>/src/test/java
or<PROJECT>/target/test-classes
Project Properties\Java Build Path(Tab)Source : Outputfolder for
<PROJECT>/src/test/java
as well as<PROJECT>/src/test/resources
must be<PROJECT>/target/test-classes
项目属性\部署程序集:必须没有条目
<PROJECT>/src/test/java
或<PROJECT>/target/test-classes
回答by Jeff
When this happens, perform "Maven -> Update Project..." from the project properties context menu. In my experience, this correctly reconfigures Eclipse.
发生这种情况时,从项目属性上下文菜单中执行“Maven -> Update Project...”。根据我的经验,这会正确地重新配置 Eclipse。