在 pom.xml 引入如下依赖:
<dependencies>
<!-- spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.9.RELEASE</version>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.14</version>
</dependency>
<!-- junit测试 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- 指定源码的位置 -->
<sourceDirectory>src/main/java</sourceDirectory>
<!-- 指定测试的位置 -->
<testSourceDirectory>src/test/java</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<!-- 字符集编码 -->
<encoding>utf-8</encoding>
<!-- 源代码使用的jdk版本 -->
<source>1.8</source>
<!-- 编译使用的jdk版本 -->
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>