Spring-boot Minimum Demo

Source: Internet
Author: User

POM file, note the red part:

<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion> <groupId>spring-boot-starter-data-mongodb</groupId> < Artifactid>spring-boot-starter-data-mongodb</artifactid> <version>0.0.1-SNAPSHOT</version> <parent> <groupId>org.springframework.boot</groupId> <artifactid>spring -boot-starter-parent</artifactid> <version>1.5.1.RELEASE</version> </parent> ;<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies><build>
<!--springboot packaged plug-in (packaged jars can be started directly with the "Java-jar Your_jar.jar" command)-<sourcedirectory>src& lt;/sourcedirectory> <plugins> <plugin> <groupid>org.springframework .boot</groupid> <artifactId>spring-boot-maven-plugin</artifactId> <exec utions> <execution> <goals> <GOAL&G t;repackage</goal> </goals> </execution> </e xecutions> </plugin> </plugins> </build></project>

Program Entry:

 PackageCom.cui;ImportOrg.springframework.boot.CommandLineRunner;Importorg.springframework.boot.SpringApplication;Importorg.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication Public classApplicationImplementsCommandlinerunner { Public Static voidMain (string[] args) {springapplication.run (application.class, args); } @Override Public voidRun (String ... args)throwsException {System.out.println ("The logic that executes after spring is loaded can be used directly with the spring context, as well as dependency injection @autowired"); }}

The simplest Web application (However, this is not the point, just a simple example of spring-boot-starter-web build in pom, more components reference http://www.mvnrepository.com/search?q= spring-boot-starter-):

 PackageCom.cui;Importorg.springframework.web.bind.annotation.PathVariable;Importorg.springframework.web.bind.annotation.RequestMapping;ImportOrg.springframework.web.bind.annotation.RestController, @RestController @requestmapping ("/USER") Public classUsercontroller {@RequestMapping ("/{id}")     PublicString View (@PathVariable ("id") (Long ID) {returnID + "~"; }}

Spring-boot Minimum Demo

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.