When using Spring and Maven, what is the best way to deploy the code to the server?
I have a project that uses Spring. Every time I deploy, I run the maven goal "package", which runs all the tests and creates the war file. Then I manually use an ftp program to copy the war file to the server. I then run a bash script to shut down the server, replace the war and start up the server again.
Sometimes when they are changes done to the database schema, I have to run a sql migration script manually.
Is there a better workflow I can use? As the project's war file gets to be 60MB, I am having to wait 10-12 minutes to upload it to the server. If I realize that one little thing needs to be changed, I have to do the whole process all over again.
It's doubly bad for me because on DSL, upload bandwidth kills download bandwidth, so the internet is completely inoperable开发者_JAVA百科. Even working on the project and running maven goals is slow because they use the internet connection to look for dependencies all the time.
Is there a better way to work? Thanks.
First of all you could avoid manual ftp copies by using the Maven Deploy plugin. You can find an how-to to deploy projects over ftp at this URL:
http://maven.apache.org/plugins/maven-deploy-plugin/examples/deploy-ftp.html
Second point is a question about your project: is your WAR size normal?
I've heard of configurations that embedded superfluous jar in order to avoid the problem of META-INF/spring.handlers overwriting when building the final jar. If you're in this situation, you might be interested by this too:
http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html
精彩评论