Discussion on the packaging method of Java project __java
Source: Internet
Author: User
We all know that developing a Web service in Java is cumbersome, requiring a variety of frameworks, configurations, and, after that, a war package that needs a servlet container, Tomcat, or Jetty,jboss to run the release, the same thing, You'll find it's very simple in other languages, like the Django in Python or the rails in Tornado,ruby, and with the popularity of micro-services in recent years, a simple, powerful, flexible, easily configurable, easily developed Web service is imminent, And it's spring Boot, which unifies the framework of the various needs of Java Web Development and provides all-inclusive support. Here is not specifically introduced, there is a need for friends, can see the scattered fairy wrote a few articles on its http://qindongliang.iteye.com/blog/2205633.
Spring boot makes it easy to develop micro services. Of course, it is not limited to micro services, it can also be integrated with the Dubbo to achieve enterprise-class service, because spring boot has the servlet container embedded, when the service is published, only a jar package, all related dependencies in this jar package, So there's no need for you to download a tomcat or jetty to run the service, this jar package, copied to any machine that has a JDK environment, can run at will, and besides, because there is only one jar package, it's very convenient to integrate with Jekins and Docker, This way will gradually become popular, and the war package + external container distribution way of the forecast will gradually decline, here is not specifically introduced this packaging.
And then the interview, because everything is in this jar package, and when you rely more and more, the volume of this jar package will go up badly, and in one of our scenarios, we have integrated dubbo,redis,solr,hadoop,hbase, the last Jar package volume, Close to 100M, however, large enough to be secondary, as long as the service can function correctly, you can ignore this small disadvantage, then start, stop the script is very concise:
Startup script:
The above scattered fairy talked about the spring boot can encapsulate all the dependencies into a jar package, if you need to configure the various running parameters in advance, and then compile and package, run this jar, if it has been published to the server, I would like to change some parameter configuration, how should I do it. At this point you will find that you can't do anything with a jar, unless you go back to the MAVEN project, change the configuration parameters inside, then repackage it, and then use Jenkins to release it to Docker, if at this time, you upload to the server very slow speed, dozens of kb/seconds, It happens that you have a 100M jar, also not published to SE years, here is not exaggerated, is the actual development may encounter a situation.
So how to better deal with this problem. In fact, it is not difficult, in the packaging, the separation of works, forming a basic directory as follows:
See the above directory, do you guys have the feeling of getting back to Ant's age, but not in Maven, we can use the Maven-assembly-plugin plug-in to do more elegant packaging
mode, only in the project, the following two parts of the change can be completed:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service