02.eclipse创建项目.txt
UP 返回
参考网页:https://www.cnblogs.com/LUA123/p/8110285.html
备注:采用的即是方法1
1.新建Maven工程
2.配置工程信息,注意打包为jar
3.打开pom.xml文件,添加spring-boot依赖
<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</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
4.新建文件src/main/hello/HelloController.java
package hello;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/")
public String hello(){
return "Greetings from Spring Boot!";
}
}
5.新建src/main/hello/Application.java
package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
// http://localhost:8080/
SpringApplication.run(Application.class, args);
}
}
6.运行Application,启动成功
DOWN 返回