maven配置文件说明.txt
UP 返回
1.以下即为文件pom.xml内容
<?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>org.example</groupId>
<artifactId>mybatis_test</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!--单元测试-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<!--mybatis核心-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.2.8</version>
</dependency>
<!--数据库确定-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>commons-lang</groupId>-->
<!-- <artifactId>commons-lang</artifactId>-->
<!-- <version>2.5</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!--▶构建相关的东西由插件管理-->
<!--处理资源被过滤的问题-->
<build>
<plugins>
<!--▶maven3默认支持的是jdk1.5编译,所以需要用1.8的话要配上这个-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source><!--▶源代码使用的jdk版本-->
<target>1.8</target><!--▶需要生成的目标class文件的编码版本-->
<encoding>UTF-8</encoding><!--字符集编码-->
</configuration>
</plugin>
</plugins>
<!--▶一般资源文件都放在resources里,如果遵守的话就不用配下面这个配置-->
<!--▶但是如果懒得移动,直接在java文件夹中写配置文件,配上这个项目就也可以读到配置了-->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project>
2.maven项目有时候写代码使用@时无法获得所需的类,比如:
@RunWith(SpringJUnit4ClassRunner.class) //这个地方报错
public class EmployeeServiceImplTest extends TestCase
但是可以通过鼠标点到对应的类上去,可以看看pom里对该类的依赖是不是加上了test的限制,去掉就可以了:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
<!-- <scope>test</scope> --> //■去掉
</dependency>
DOWN 返回