MAVEN Configuration Spring Boot

Source: Internet
Author: User

1. Install maven:1) Download MAVEN package 2) Extract package 3) Add environment variable Maven_home=maven after decompression path 4) Add after environment variable path;%maven_home\bin%; 5) Run mvn-v in CMD to see if MAVEN is installed successfully 2. Create a MAVEN project in Eclipse: New->other->maven->maven Project 3. Edit Pom.xml:pom.xml
1.5 KB

<?xml version= "1.0" encoding= "UTF-8"?>
<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>org.springframework</groupId>
<artifactId>gs-scheduling-tasks</artifactId>
<version>0.1.0</version>
<!--
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.3.RELEASE</version>
</parent>
-
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>1.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.2.3.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project> 4. Save POM.XML5. The Java file where the main function is edited is as follows: Test.java
683 bytes

Package Com.lenovo;

/**
* Hello world!
*/

Import org.springframework.boot.*;
Import org.springframework.boot.autoconfigure.*;
Import org.springframework.stereotype.*;
Import org.springframework.web.bind.annotation.*;

@Controller
@EnableAutoConfiguration
public class App {

@RequestMapping ("/")
@ResponseBody
String Home () {
Return "Hello world!";
}

public static void Main (string[] args) throws Exception {
Springapplication.run (App.class, args);
}
@RequestMapping (value = "/test", method = Requestmethod.get)
@ResponseBody
public static String HelloWorld () {
Return "Hello World";
}
}6. Compile and run the program in the browser input: Http://127.0.0.1:8080/test Enter, the word "Hello world" appears in the browser

MAVEN Configuration Spring Boot

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.