How to prevent eclipse from deploying test classes on Tomcat?

14,000

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-classesenter image description here

Solution 2

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

Share:
14,000
Ralph
Author by

Ralph

Updated on June 03, 2022

Comments

  • Ralph
    Ralph almost 2 years

    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?

  • membersound
    membersound about 10 years
    For me it was sufficient to just exclude any src/test folders from Deployment Assembly.
  • Pavel
    Pavel over 9 years
    This 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
    DavidDunham about 2 years
    How do I exclude folders? I can only "add" ...
  • Ralph
    Ralph about 2 years
    @DavidDunham: are you talking about subfolders in one of the folders listed in that dialog?