标签:stc prope maven work ret config png ack div
一、引入依赖
1.springboot项目必须继承springboot父工程
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-parent</artifactId> <version>1.5.9.RELEASE</version> </parent>
2.springboot开发web项目,所需要的依赖(也叫场景启动器)
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
项目的pom.xml文件
<?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.company</groupId> <artifactId>springbootDemo</artifactId> <version>1.0-SNAPSHOT</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-parent</artifactId> <version>1.5.9.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> </project>
二、编写配置文件application.properties(可以不写任何东西)
三、创建相关类
如上图
IndexController类
package com.company.hf.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; /** * @Author wangsy * @Date 2019/10/9 15:16 **/ @RestController public class IndexController { @GetMapping("/index") public String hello(){ return "hello"; } }
BootApplication类是该项目的启动类
package com.company.hf; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * @Author wangsy * @Date 2019/10/9 15:16 **/ @SpringBootApplication public class BootApplication { public static void main(String[] args) { SpringApplication.run(BootApplication.class,args); } }
标签:stc prope maven work ret config png ack div
原文地址:https://www.cnblogs.com/itheima-wsy/p/11645094.html