首页 > 代码库 > Springboot入门
Springboot入门
pom.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4 <modelVersion>4.0.0</modelVersion> 5 6 <groupId>douya</groupId> 7 <artifactId>Blog_SpringBoot</artifactId> 8 <version>0.0.1-SNAPSHOT</version> 9 <packaging>jar</packaging> 10 11 <name>spring-web-demo</name> 12 <description>Demo project for Spring WebMvc</description> 13 14 <parent> 15 <groupId>org.springframework.boot</groupId> 16 <artifactId>spring-boot-starter-parent</artifactId> 17 <version>1.3.5.RELEASE</version> 18 <relativePath/> 19 </parent> 20 21 <properties> 22 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 23 <java.version>1.8</java.version> 24 </properties> 25 26 <dependencies> 27 <dependency> 28 <groupId>org.springframework.boot</groupId> 29 <artifactId>spring-boot-starter-web</artifactId> 30 <!-- spring-boot-starter:核心模块,包括自动配置支持、日志和YAML --> 31 </dependency> 32 </dependencies> 33 34 <build> 35 <plugins> 36 <plugin> 37 <groupId>org.springframework.boot</groupId> 38 <artifactId>spring-boot-maven-plugin</artifactId> 39 </plugin> 40 </plugins> 41 </build> 42 43 44 </project>
src/main/java/a/
1 package a; 2 3 import org.springframework.boot.SpringApplication; 4 import org.springframework.boot.autoconfigure.SpringBootApplication; 5 import org.springframework.web.bind.annotation.RequestMapping; 6 import org.springframework.web.bind.annotation.RestController; 7 8 @SpringBootApplication 9 @RestController 10 public class Application { 11 12 @RequestMapping("/") 13 public String greeting() { 14 return "Hello World2!"; 15 } 16 17 @RequestMapping("/p") 18 public String greeting2() { 19 return "Hello World pp2!"; 20 } 21 @RequestMapping("/h") 22 public String greeting3() { 23 return "Hello World pp2!"; 24 } 25 26 public static void main(String[] args) { 27 SpringApplication.run(Application.class, args); 28 } 29 }
Springboot入门
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。