Today I learned the more popular framework spring Boot, feel Springboot's advantage lies in the support of various components, through a few short configuration can be done before a lot of operations to complete the plug-in implant. Let the programmer put more time on the thinking of business logic, Save time cost, this is my first time to write a blog, there is nothing bad place hope to correct, the following to start Springboot study:
Springboot specific introduction can see other online introduction, here is not much to say, on these days of study, personal understanding, in short:
(1) It is the spring upgrade version, the spring container can do things, it can do, and more convenient, from the configuration form, Springboot completely abandoned the cumbersome way of XML file configuration, but instead of annotated way to achieve, although essentially, is similar (like packet scanning, annotation scanning, class loading, and so on).
(2) Springboot integrated plug-in more, thus using a lot of services, all just introduce a dependency, a few annotations and Java classes can be used, specific reference related manuals.
(3) In the Web application development of this piece, the previous application is generally packaged into a war package, and then published to the relevant server container (such as Tomcat), although Springboot can also do so, But the more common form under springboot is to package the Springboot app into an executable jar package file. The reason for this is that you can directly think of the Springboot application as a Java application, whose Web application can have no WebApp directory (not to mention XML), which recommends using HTML pages and using them as static resources.
The following specific record, how to start from scratch under idea, step by step to build Springboot Web application, here is Maven for dependency management, novice start, have any questions, please refer to Springboot official website.
It is necessary to note that Springboot relies on a JDK version of 1.8 and above.
I. Create a new MAVEN project directly File--and new project select Maven and click Next:
Second, fill in the project name
Three click Next to complete the creation of the MAVEN project with the following directory structure:
Iv. Adding a Spring boot dependency through maven
1 <parent> 2 <groupId>org.springframework.boot</groupId> 3 <artifactId>spring-boot-starter-parent</artifactId> 4 <version>1.5.1.RELEASE< /version> 5 </parent> 6 <dependencies> 7 <dependency> 8 <groupId>org.springframework.boot</groupId> 9 <artifactId> spring-boot-starter-web</artifactid> </dependency> </dependencies >
Five. After the jar package is imported, create a new controller and complete the official Spring boot instance (to ensure that Mavan downloads the dependent jar package for springboot):
1 /**2 * Created by Song on 2017/2/15.3 * Test code in the official sample project4 */5 @Controller6 @EnableAutoConfiguration7 Public classSamplecontroller {8@RequestMapping ("/")9 @ResponseBodyTen String Home () { One return"Hello world!"; A } - - Public Static voidMain (string[] args)throwsException { theSpringapplication.run (Samplecontroller.class, args); - } -}
Notice that there is a main function, and then it is said that the Springboot application is generally packaged into an executable jar package to publish, and this main function is the entry for the entire project. The reason why you can do this is because springboot even Tomcat8 as a plug-in, so it doesn't have to be the same as the previous SSM architecture, and you need to configure the war package under Tomcat to run. Directly click to run the main function, and then the browser link bar, enter the address http://localhost:8080/, you can see the printed string "Hello world!" The This is one of the most basic springboot-based Web applications available on the website, so it's easy.
This essay draws lessons from: http://blog.csdn.net/u013248535/article/details/55100979
Learning Springboot Framework