How to prevent eclipse from deploying test classes on Tomcat?
Solution 1
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
Solution 2
When this happens, perform "Maven -> Update Project..." from the project properties context menu. In my experience, this correctly reconfigures Eclipse.
Ralph
Updated on June 03, 2022Comments
-
Ralph almost 2 years
I have a Maven project, containing the typical folders
src/main/java
andsrc/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 fromsrc/test/java
folder too.I do not want the test classes deployed, so how can I "exclude" that directory from eclipse-tomcat deployment?
-
membersound about 10 yearsFor me it was sufficient to just exclude any
src/test
folders fromDeployment Assembly
. -
Pavel over 9 yearsThis workaround works if you do not need to change maven profiles. I've got a project configured with maven profiles and whenever I change them, m2e reconfigures the deployment assembly and I need to go and edit it again.
-
DavidDunham about 2 yearsHow do I exclude folders? I can only "add" ...
-
Ralph about 2 years@DavidDunham: are you talking about subfolders in one of the folders listed in that dialog?