Springboot~ Getting Started first article ~

Source: Internet
Author: User

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 ~

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.