标签:浏览器 template uri 它的 pos port mvc autoconf snapshot
Spring Boot(简称SB)用于简化Spring应用的配置过程。
采用“习惯优于配置”的方式开发
学习SPB其实就是掌握它的各项约束与要求。
会用Maven和Spring MVC
/test 测试文件目录
打包与独立运行
创建resources/application.properties,SPB核心配置文件
spring-boot-maven-plugin 提供SPB应用打包的功能
<?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.qiyi</groupId>
<artifactId>myspringboot</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
server.port=80
package com.qiyi.myspringboot.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class MyController {
@RequestMapping("/out") //绑定到out地址
@ResponseBody //直接向浏览器输出
public String out(){
return "success";
}
}
package com.qiyi.myspringboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
//告诉SpringBoot我是一个入口类,运行我就能启动SB
//会自动扫描可以被注入的类,并初始化
//@Repository / @Service / @Controller / @Component / @Entity
@SpringBootApplication
public class MySpringBootApplication {
public static void main(String[] args) {
//启动SpringBoot,并初始化相关的组件
SpringApplication.run(MySpringBootApplication.class);
}
}
标签:浏览器 template uri 它的 pos port mvc autoconf snapshot
原文地址:https://www.cnblogs.com/itlaoqi/p/11387522.html