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