标签:dea bind ati public cat string gap world str
编辑器IDEA,运行环境jdk-1.8
<!--springboot依赖-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * @SpringBootApplication标注一个主程序,说明这是一个springboot应用 */ @SpringBootApplication public class HelloWorld { public static void main(String[] args) { /*启动spring应用*/ SpringApplication.run(HelloWorld.class,args); } }
import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller public class HelloController { @ResponseBody @RequestMapping("/hello") public String hello(){ return "hello world!"; } }
<!--该插件可以将应用打包成可执行的jar包-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

cmd运行方式:
进入jar所在目录,(这里你的jar包名称为xxx.jar)
java -jar xxx.jar
即使运行环境没有tomcat也能运行
标签:dea bind ati public cat string gap world str
原文地址:https://www.cnblogs.com/nirvanaInSilence/p/12332799.html