springboot
一、配置Maven
1、Configure>Settings
2、Build,Execution,Deployment>Build Tools>Maven>Maven home directory
二、使用Maven方式构建
1、点击Create New Project
2、选择Maven,点击Next
3、填写域名GroupId和ArtifactId,点击Next
4、点击Finish
5、配置pom.xml
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.8.RELEASE</version> </parent> <dependencies> <!--引入springmvc web模块--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> <build> <plugins> <!--加入打包依赖--> <!--<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin>--> </plugins> </build>
6、Controller
TestController.java
package com.zj.controller; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RequestMapping; @RestController public class TestController { @RequestMapping("/hello") public String testHello() { return "hello"; } }
7、application.properties文件可以改变配置属性
server.port=8888
8、启动类
MainClassStart.java文件
package com.zj; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class MainClassStart { public static void main(String[] args) { SpringApplication.run(MainClassStart.class,args); } }
9、使用启动类main方法启动
10、输入网址
localhost:8888/hello
11、pom.xml支持jar
链接:https://pan.baidu.com/s/1USffaVIrZIr_BxVV93TRTA
提取码:8888