1

I am running a Spring Boot application (java main function) in the eclipse. It is a maven based project. I think eclipse uses m2e plugin to run it. But every time I run my project, the test-classes folder is added to the classpath in the final command.

1]

I have to manually remove the test folder (src/test/java and src/test/resources) from source folder in all sub-projects. But when I right click the project, Maven -> Update Project... , the test folder be added to source folder again automatically. Then the final test-classes folder be added into classpath for the run command.

Chris
  • 6,431
  • 10
  • 44
  • 59
  • How are you executing it from Eclipse? – khmarbaise Dec 01 '17 at 07:39
  • As I said, my app is a Spring Boot Application, I just right click the class file which has the main function, then select Run As -> Java Application – Chris Dec 01 '17 at 08:31
  • Ah...Ok. What about running/testing from command line via `mvn spring-boot:run`.... – khmarbaise Dec 01 '17 at 16:14
  • @Chris What do you mean by sub-projects? Are they Maven modules? How are they wired together? Or more specifically how `nqsky-meap-open` referred from `api-server`? Test-classes are not added by Eclipse to the runtime-classpath (usually), so there might be some configuration problem there. – helospark Dec 01 '17 at 19:53
  • @helospark Sub-projects means sub-module of Maven. We have a parent module for all the projects. And then there is a main module, in its pom.xml file, all other sub-modules are declared as dependencies. The main module test-classes are not included in the runtime classpath, but the sub-modules did. – Chris Dec 04 '17 at 07:00
  • any update on this? or eclipse doesn't have any way to exclude test folder? – Neha Choudhary Oct 14 '19 at 09:05
  • 1
    @NehaChoudhary A similar question is posted and the answer seems to be relevant here as well - https://stackoverflow.com/a/62554182/979772 – divinedragon Jun 24 '20 at 11:40

1 Answers1

0

In current Eclipse version there is a checkbox "Exclude test code" in Dependencies tab to exclude src/test sources.

Eilema
  • 1