We have a web application (Java
+ Tomcat
+ Spring
+ Maven
) that depends on resources. So the app-1.0.1.war
depends on the resources-1.0.3.jar
. When we need to fix a bug in the resources, we need
- release a new resources jar => 1.0.4
- update the dependency in the maven pom of the web app
- release a new war => 1.0.2
- deploy the web app
In our team some people think that it's a not an efficient way to do. They开发者_开发百科 would prefer to
- release a new jar
- upload the jar on the server
So basically no redeployment of the app. It seems easier but I can see several problems with this approach:
- You need to hard code the name of the jar that contains the resources.
- You don't know the version of the resources the app is using.
What is the common practice to update static resources of a web application?
We follow a similar approach with our projects as well.
- release a new resources jar => 1.0.4
- update the dependency in the maven pom of the web app
- release a new war => 1.0.2
- deploy the web app
There are a number of reason to do this, these are some of the ones that stick out for me:
- Our internal jar files (modules) are re-used throughout a number of projects. Older projects may break with new releases.
- While point-versions that are written for a single application may not cause any trouble, significant releases could break the entire app. Serious integration testing would be required before being able to do such releases.
- If you have inter dependencies such as the main application requiring version 1.0.4 and another module requiring 1.0.1 - the main application will always win this tie-breaker. If version 1.0.4 breaks the aforementioned module, you will have to fix it before you can deploy your project.
If none of these apply to you, consider reading Dependency Version Ranges in the Maven documentation. Something like this should accomplish what you're trying to do:
<version>LATEST</version>
Edit:
So basically no redeployment of the app
This is untrue, the resources would only be updated each time mvn install
is run - every time you build a war.
So yes, you will always have the most updated jar during development but an older war would not suddenly be bundled with freshly released jars on the fly. And trust me, you definitely do not want that.
You are only cutting out one step:
- update the dependency in the maven pom of the web app
You're adding a lot of risk to remove one step. Check out the link I posted above, it might give you some more fitting alternatives. LATEST
is probably not what you're looking for.
精彩评论