1.新建工程:
new maven project->create a simple project:
Gid -> Aid -> jar package
2.配置springboot:
pom.xlm:
(1)继承:
<!-- https://spring.io/projects/spring-boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath/><!-- lookup parent from repository -->
</parent>
(2)依赖:
从parent点ctrl进去,再从dependencies点ctrl进去,检索starter-web:
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>
(3)jdk版本:
从parent点ctrl去,检索maven-compiler-plugin点ctrl进去:
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
3.工程文件:
新建类,添加注解->
@enableautoconfigure
@controller
新建方法,添加注解:
@requestmapping
@responsebody
main函数,启动服务:
SpringApplication.run(类名字节码,args);
4.配置文件:
工程配置:application.yml:
server:
port(空格):value
启动文本:banner.txt
文本内容(字符画http://patorjk.com/software/taag)
5.调试:
右键,run as