maven排除依赖和添加本地依赖
1.在需要引用依赖包的包配置下添加exclusions标签,在里面添加一个排除依赖项,
如下图所示:
<dependency> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-starter-webartifactId> <version>2.0.8.RELEASEversion> <exclusions> <exclusion> <artifactId>spring-boot-starter-tomcatartifactId> <groupId>org.springframework.bootgroupId> exclusion> <exclusion> <artifactId>log4j-to-slf4jartifactId> <groupId>org.apache.logging.log4jgroupId> exclusion> exclusions> dependency>
2.在dependencies标签里添加一个dependency标签,引入一个本地的jar包,
${pom.basedir}有时可以用${project.basedir}代替,有时会报错,视具体情况而定。
如下图所示:
<dependency> <groupId>org.apache.logging.log4jgroupId> <artifactId>log4j-to-slf4jartifactId> <version>2.15.0-rc2version> <scope>systemscope> <systemPath>${pom.basedir}/src/main/webapp/log4j-to-slf4j-2.15.0-rc2.jarsystemPath> dependency> <dependency> <groupId>org.apache.logging.log4jgroupId> <artifactId>log4j-apiartifactId> <version>2.15.0-rc2version> <scope>systemscope> <systemPath>${pom.basedir}/src/main/webapp/log4j-api-2.15.0-rc2.jarsystemPath> dependency>
3.本地引入的jar包在打包时并不会自动打到jar包里,需要手动设置,设置如下:
<build> <plugins> <plugin> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-maven-pluginartifactId> <configuration> <includeSystemScope>trueincludeSystemScope> configuration> plugin> <plugin> <groupId>org.mybatis.generatorgroupId> <artifactId>mybatis-generator-maven-pluginartifactId> <version>1.3.7version> <configuration> <verbose>trueverbose> <overwrite>trueoverwrite> configuration> plugin> plugins> build>