Thursday, December 21, 2017

Eclipse deletes files/folders from deploy path during build

Leave a Comment

I have two maven projects in eclipse webapp and serviceImpl. webapp references serviceImpl.

When serviceImpl project is closed in eclipse and I build and run the webapp on Tomcat, the application works fine. But when I run webapp while serviceImpl is open, I get the error, that HTTP Status 500 - Configuration problem: Failed to import bean definitions from URL location [classpath:META-INF/serviceimpl-context.xml]. If I look into the META-INF folder on the machine I see that eclipse has deleted the xml file.

When I build and run the application on the command line or in IntelliJ, the problem does not appear either.

In eclipse the Deployment Assembly settings of webapp contains the open serviceImpl project and sourcereferences to some serviceImpl-2.0.0-SNAPSHOT.jar.

Also Java Build Path --> Libraries --> Maven Dependencies has the serviceImpl node:

enter image description here

We are also using Spring Application Context.

EDIT:

When I do on the commandline:

mvn clean install -P build-modules-test -Dmaven.test.skip=true

then the xml file is created and the application works fine. But in eclipse "right-click project --> Maven --> Update project" deletes these files, but does not create them again...so the error occurs

1 Answers

Answers 1

As I commented, an "update project" is not the same as an mvn install: the files are created during the package stage, stage which is not called during an Eclipse update.

See "Developing with Eclipse and Maven / Running Maven Builds"

You can define a Launch Execution setting with all the parameters you need:

https://books.sonatype.com/m2eclipse-book/reference/figs/web/running_run-config.png

Then you are sure to execute the same stages as the one done in command line through mvn install.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment