简体   繁体   中英

How to prevent eclipse from deploying test classes on Tomcat?

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.

I do not want the test classes deployed, so how can I "exclude" that directory from eclipse-tomcat deployment?

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.

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 在此输入图像描述

When this happens, perform "Maven -> Update Project..." from the project properties context menu. In my experience, this correctly reconfigures Eclipse.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM