这里写目录标题
Maven配置文件
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- springboot核心包 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>cn.qileyun</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!--在以往的导入包中需要导入vision版本,当是这里spring boot已经帮我们定义好了-->
<!--spring-boot-starter 所有spring boot依赖都是使用这个开头-->
<!--spring-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!--测试-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--web依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<!-- 打jar包工具-->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Spring boot配置文件
以往我们需要在xml中配置这些参数,现在只需要在spring boot配置文件中进行修改,这样大大减少我们创建和配置文件的时间。当然你不写这些配置文件spring boot也帮我们做好类默认配置
如果你想要查看需要配置那些参数可以进入这个文件查看
两种配置文件
- propertied
- yaml
让我们比较这2种写法
#k v
#name = hello
name: hello
# 对象
student:
name: hello
age: 3
# 行内写法
student1: {name:hello,age:3}
#数组prop就无法实现了
# 数组
pets:
-car
-dog
-pig
pets:[cat,dog.pig]
name=hello
student.name = hello
student.age = 3