标签:string rop port gap run targe ase 一个 新建
在E:\Developing\DevTools\apache-maven-3.6.1\conf\settings.xml文件下新增配置
<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>
新建maven项目,打为jar包即可
导入springboot相关依赖
<!-- Inherit defaults from Spring Boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.22.RELEASE</version>
</parent>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
package com.fei;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @SpringBootApplication 来标注一个主程序类,说明这是一个spring boot应用
* @author Del
*
*/
@SpringBootApplication
public class HelloWorldMainApplication {
public static void main(String[] args) {
// 启动springboot应用
SpringApplication.run(HelloWorldMainApplication.class, args);
}
}
package com.fei.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HelloWorldController {
@ResponseBody
@RequestMapping("/hello")
public String hello() {
return "Hello World!";
}
}
在浏览器输入地址http://localhost:8080/hello
即可看到Hello World!
导入插件
<build>
<plugins>
<!-- 这个插件,可以将应用打包成一个可执行的jar包 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
打包,cmd窗口,通过java -jar spring-boot-01-helloworld-0.0.1-SNAPSHOT.jar
的方式运行。
标签:string rop port gap run targe ase 一个 新建
原文地址:https://www.cnblogs.com/zxfei/p/11588348.html