estesMX
estesMX

Reputation: 29

Java How 'refresh' jars in a war file

I'm debugging a project, but when a create a warfile the jars inside don't seems to be up to date, (i made those jars). I realized about this issue when i was testing the war file on the server, i modified one of the jars to send a message when the server receives a petition.

This message is never sent. There is a command like the 'mvn clean package' to re-build all the project?. I create the war file like this jar cvf web-archive.war.

Upvotes: 0

Views: 453

Answers (2)

Mikhail Chibel
Mikhail Chibel

Reputation: 1955

As per other comments, most likely your libraries jars are not updated. You need to rebuild them before creating war file. if you already using maven for libraries why not to use

There is a command like the 'mvn clean package' to re-build all the project?

Yes, there is such a command and it will rebuild the project. But keep in mind, that it will not rebuild projects the current project is dependent on (i.e your libraries). You need to run this command for all 'libraries' projects.

I will suggest to use mvn clean install instead as it will rebuild your project and put the jar into your local maven repository so all other projects can use your locally build jar.

As you already using maven why not use it to build your war files as well. This is super convenient. Have a look at Maven WAR plugin

Upvotes: 2

pmorken
pmorken

Reputation: 784

A possible cause: you've updated your jar file without changing the version number causing maven to assume it can use an outdated cached copy. Occasionally I've had to:

  • delete my target folder
  • remove the artifact(s) from my local .m2/ cache
  • mvn clean install the dependencies
  • mvn clean package my project

Upvotes: 1

Related Questions