先解决一个问题【报错1】java: 无效的目标发行版: 17
修改位置:maven的配置需要改为选取本地maven所在目录(这些都是java指定了1.8比较低但是又都用的版本导致)

再解决一个问题【报错2】
java: 无法访问org.springframework.boot.SpringApplication
错误的类文件: /D:/apache-maven-3.8.6/maven-repo/org/springframework/boot/spring-boot/3.0.1/spring-boot-3.0.1.jar!/org/springframework/boot/SpringApplication.class
类文件具有错误的版本 61.0, 应为 52.0
请删除该文件或确保该文件位于正确的类路径子目录中。
这个错误应该是spring boot版本过高导致
基于

重新建立一个spring boot 项目,版本应该小于3,亲测有效

第三个问题
Spring Boot Configuration Annotation Processor not configured
在帮助文档
Spring Boot Reference Documentation
中找到
![]()
3.1. Configuring the Annotation Processor
pom引入依赖,Maven刷新
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
同时确保build时不用build上面的这个Processor
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
以下提示代表需要重新启动项目 Re-Run Spring Boot Configuration Annotation
![]()
注意: make sure that the lombok dependency is defined before the spring-boot-configuration-processor dependency. 去报lombok依赖定义要在上面的依赖前面
用Maven Clean&Package

复制打包文件到本地

打开,看上去无论写不写exclude里面都没有pring-boot-configuration-processor
这个或许是默认不打包吧

YAML
适用于以数据为中心的配置
语法: Key: value 有一个空格
大小写敏感
使用缩进表示层级关系
缩进不建议用tab,只用空格
缩进空格数不重要,只要相同层级的元素左对齐即可
字符串无需加引号
# 注释 ‘’ “”表示其他意义
数据类型
字面量 date boolean string number null
对象:键值对集合 map hash set object
k: 行内写法{k1:v1,k2:v2,k3:v3}或者
k:
k1:v1
数组 array list queue
行内写法 k: [v1,v2,v3]
或 k:
- v1
- v2 用一个横杠代表一个元素
使用YAML
创建文件,可以写成yml或者yaml

properties和yml都会生效,前者优先
如下,使用@Component使该类bean加入容器中
使用@ConfigurationProperties(prefix = "person")与上图两个配置文件前缀为person的属性绑定
@ConfigurationProperties(prefix = "person")
@Component
@ToString
@Data
public class Person {
private String userName;
private Boolean boss;
private Date birth;
private Integer age;
private Pet pet;
private String[] interests;
private List[] animal;
private Map<String,Object> Score;
private Set<Double> salarys;
private Map<String,List<Pet>> allPets;
}
编写配置文件:字符串也可以用单引号或双引号标记
但是如果里面有\n 在作为json输出到页面上差别不大,但是如果在controller里面输出对象属性,就会有以下差别
单引号会改变它的行为,就是作为普通字符串输出
双引号则 尊重\n换行的行为,原样输出
userName这种驼峰也可以写成user-name也是有效的
person:
userName: 李白
boss: true
birth: 2011/11/22
age: 18
#interests: [篮球,足球]
interests: #list
- 篮球
- 足球
- 乒乓球
animal: [猫,狗]
# Score:
# english: 80
# math: 90
Score: {English: 80,Math: 90} #map {}内不必有空格,为json写法
salarys:
- 998
- 777
pet:
name: 阿花
weight: 98.77
allPets:
sick:
- {name: 阿飞,weight: 78.7} #第1种对象表示法
- {name: 阿歪,weight: 65.3}
- name: 阿园 #第二种对象表示法 -代表一个元素
weight: 99
health:
- {name: 阿花,weight: 18.7}
- {name: 阿斗,weight: 38.3}







![[综][PDPTW]A survey on pickup and delivery problems](https://img-blog.csdnimg.cn/1e736345a94a4beb9a6e12e20483629d.png)











