使用maven建立普通的maven jar项目
1配置pom文件
<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>cn.ps</groupId>
<artifactId>STRINGBOOT</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent> <!--集成springboot的父项目 统一进行版本管理-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.17.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
写一个简单的Hello World
package cm.ps;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
public class Example {
@RequestMapping("/")
String home() {
return "Hello World!";
}
@RequestMapping("/j")
HashMap home1() {
HashMap map=new HashMap();
map.put(1, "张三");
return map;
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Example.class, args);
}