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