In the Java development project often to the development of the project to the test server to test, the general is to put the project into a war package, and then publish the war package to the server, shut down the server, and finally restart the server, although this process is not very cumbersome, but if it is a number of projects to be published, The release process will be cumbersome, so the gospel comes ...
By writing a shell script to do this, the project can be automatically published to the server as long as a shell script is executed, and it is still easier to use.
The first step: Install SVN in Linux. (This can refer to another blog:http://simplelife.blog.51cto.com/9954761/1729931 ), specific to this blog, SVN was installed to use some of the commands in SVN.
Step two: Install Maven on Linux. (Reference:http://simplelife.blog.51cto.com/9954761/1743977 )
The third step: under any directory in Linux, it is best to create a new directory yourself, such as the Ucenter directory
12345 |
mkdir /home/softs/ucenter cd ucenter svn co http: //svnserver/mypro/trunk ./ #从指定的svn地址中检出代码到当前目录 此时需要输入一些svn的用户名和密码,输入之后确定使用就是了。 |
Execution: SVN co http://svnserver/mypro/trunk/./
At this point the code in SVN has been checked out to the server ...
Execution under current directory: SVN up
Update the latest code in SVN and return to the SVN version
Go to the Ssm-parent directory and execute the command (Maven command): mvn-u clean Install
Enter SIMPLE-SSM to perform the same operation:
At this point there is one more directory in SIMPLE-SSM: Target, the war package for this project is in it.
Now that the Project war package has been generated, you can then copy the war to the Tomcat server and restart the server.
As mentioned above, these update codes, packaging, moving the war package to the server, and restarting the server can all be done with a simple shell script.
++++++++++++++++++++++++++++ write the shell script to be executed ++++++++++++++++++++++++++++++++
In the Ucenter directory (whichever directory, take this directory as an example)
New ssm-parent.sh File:
12 |
touch ssm-parent.sh vim ssm-parent.sh |
Write:
Exit after saving.
granting permissions to Files
Perform:
New simple-ssm.sh File:
Touch simple-ssm.sh
Vim simple-ssm.sh
Write:
Exit after saving.
granting permissions to Files
Perform:
This will release the SIMPLE-SSM project to completion.
Every time after the code is written, submitted to SVN, in the server can execute the two shell scripts (and of course, there are other projects shell script), you can easily publish the project, is not very convenient!
Perform:
12 |
./ssm-parent.sh ./simple-ssm.sh |
It is possible to publish this project at all times.
Automating deployment projects with shell scripts under Linux