springboot-helloWorld
1.maven设置:
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
2.idea中整合maven
configure-setting-Build,Execution,Deployment-Build Tools-Maven-Maven home directory
3.idea中创建maven项目helloworld
打成jar包。导入springboot相关的依赖。打成的jar包可以直接在Jdk环境下运行。
4.pom
<?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>com.lq</groupId>
<artifactId>springboot-helloWorld</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<!-- 这个插件将项目打成一个jar包 -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
5.HelloController
package com.lq.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @ProjectName: springboot-helloWorld
* @Package: com.lq.controller
* @ClassName: HelloController
* @Author: liqiang
* @Date: 2020/2/24 0024 10:39
* @Version: 1.0
*/
@Controller
public class HelloController {
@RequestMapping("/hello")
@ResponseBody
public String hello(){
return "世界,你好呵";
}
}
6.HelloWorldMainApplication
package com.lq;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @ProjectName: springboot-helloWorld
* @Package: com.lq
* @ClassName: HelloWorldMainApplication
* @Author: liqiang
* @Date: 2020/2/24 0024 10:08
* @Version: 1.0
*/
@SpringBootApplication
public class HelloWorldMainApplication {
public static void main(String[] args) {
SpringApplication.run(HelloWorldMainApplication.class,args);
}
}