Start with a new MAVEN project
menu, File----new maven, maven---maven, MAVEN project
Hook up with this Create a simple project (skip archetype selection),
Springboot is a simple MAVEN project.
Set the following parameters (write it yourself)
Use the following pom.xml data to overwrite the project's
<?XML version= "1.0" encoding= "UTF-8"?><Projectxmlns= "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>Com.how2java</groupId> <Artifactid>Springboot</Artifactid> <version>0.0.1-snapshot</version> <name>Springboot</name> <Description>Springboot</Description> <Parent> <groupId>Org.springframework.boot</groupId> <Artifactid>Spring-boot-starter-parent</Artifactid> <version>1.5.9.RELEASE</version> </Parent> <Dependencies> <Dependency> <groupId>Org.springframework.boot</groupId> <Artifactid>Spring-boot-starter-web</Artifactid> </Dependency> <Dependency> <groupId>Junit</groupId> <Artifactid>Junit</Artifactid> <version>3.8.1</version> <Scope>Test</Scope> </Dependency> </Dependencies> <Properties> <java.version>1.8</java.version> </Properties> <Build> <Plugins> <plugin> <groupId>Org.springframework.boot</groupId> <Artifactid>Spring-boot-maven-plugin</Artifactid> </plugin> </Plugins> </Build> </Project>
)
package Import org.springframework.boot.SpringApplication; Import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication Public class Application { publicstaticvoid main (string[] args) { Springapplication.run (Application. class , args);
Create a Hellocontroller.java (Controller) file
Package Springboot; Import org.springframework.web.bind.annotation.RequestMapping; Import Org.springframework.web.bind.annotation.RestController; @RestController Public class Hellocontroller { @RequestMapping ("/hello") public String Hello () { return "Hello Spring boot!" ; } }
Run the Application.java file again.
Access via Http://127.0.0.1:8080/hello
See
You're getting started, springboot.
Run-time
However, it is not enough to access the controller, but also to access the page.
Cond...
Springboot~ Getting Started first article ~