maven配置文件pom.xml添加源文件夹和测试文件夹,并且定义本项目使用JDK版本为1.8。
<build> <!-- 默认源代码和资源文件目录配置 --> <resources> <resource> <directory>${project.basedir}/src/main/java</directory> </resource> <resource> <directory>${project.basedir}/src/main/resources</directory> </resource> </resources> <testResources> <testResource> <directory>${project.basedir}/src/test/java</directory> </testResource> <testResource> <directory>${project.basedir}/src/test/resources</directory> </testResource> </testResources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>${project.build.sourceEncoding}</encoding> <compilerArguments> <verbose /> <bootclasspath>${java.home}/lib/rt.jar;${java.home}/lib/jce.jar</bootclasspath> </compilerArguments> </configuration> </plugin> </plugins> </build>
加上上面的代码后,选中项目右键,执行maven update,效果如下:
原文地址:https://www.cnblogs.com/zhuwenjoyce/p/9655836.html
时间: 2024-11-05 19:00:38