1. First create a MAVEN project in Eclipse-javaee
GROUPID:SPRINGBOOTTEST4 (name is just an example)
Artifactid:springboottest4
Open Pom.xml File
Edit the following
<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>springboottest4</groupid>
< Artifactid>springboottest4</artifactid>
<version>0.0.1-snapshot</version>
< Packaging>jar</packaging>
<name>springboottest4</name>
<url>http:// Maven.apache.org</url>
<properties>
<project.build.sourceencoding>utf-8</ Project.build.sourceencoding>
</properties>
<dependencies>
<dependency>
< Groupid>org.springframework.boot</groupid>
<artifactid>spring-boot-starter-web</ Artifactid>
<version>1.3.3.release</version>
</dependency>
</dependencies>
</project>
2. Create a new class
can refer to my:
Package com.springboottest;
/**
* @author Zzfweb
* @mail [email protected]
* Function: Demonstrate a simple example of spring boot
*/
Import org.springframework.boot.SpringApplication;
Import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
Import org.springframework.web.bind.annotation.RequestMapping;
Import Org.springframework.web.bind.annotation.RestController;
@RestController
is a controller layer annotation that handles JSON-type data
@EnableAutoConfiguration
Enable automatic configuration
public class Example {
@RequestMapping ("Index.do")
/**
* Set up the mapping, after launch, the browser input localhost:8080/index.do can be accessed
* (@RequestMapping parameters can be arbitrary, the best composite specification)
**/
String Home () {
Return "Hello Welcome to Zzfweb blog!";
Browser page Output return this sentence
}
public static void Main (string[] args) throws Exception {
Springapplication.run (Example.class, args);//Entry of the program
}
}
3, click to run, in the browser address bar input http://localhost:8080/index.do
And that's it.
=========== There is something wrong, thank you! =============
Spring Boot Starter Applet