1.在需要引用依賴包的包配置下添加exclusions標簽,在里面添加一個排除依賴項,
如下圖所示:
<!--web 模塊--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.0.8.RELEASE</version> <exclusions> <!--排除tomcat依賴--> <exclusion> <artifactId>spring-boot-starter-tomcat</artifactId> <groupId>org.springframework.boot</groupId> </exclusion> <!--排除log4j-2.x依賴--> <exclusion> <artifactId>log4j-to-slf4j</artifactId> <groupId>org.apache.logging.log4j</groupId> </exclusion> </exclusions> </dependency>
2.在dependencies標簽里添加一個dependency標簽,引入一個本地的jar包,
${pom.basedir}有時可以用${project.basedir}代替,有時會報錯,視具體情況而定。
如下圖所示:
<!-- log4j-2.x解決安全漏洞 --> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-to-slf4j</artifactId> <version>2.15.0-rc2</version> <scope>system</scope> <systemPath>${pom.basedir}/src/main/webapp/log4j-to-slf4j-2.15.0-rc2.jar</systemPath> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.15.0-rc2</version> <scope>system</scope> <systemPath>${pom.basedir}/src/main/webapp/log4j-api-2.15.0-rc2.jar</systemPath> </dependency>
3.本地引入的jar包在打包時並不會自動打到jar包里,需要手動設置,設置如下:
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <includeSystemScope>true</includeSystemScope> </configuration> </plugin> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.7</version> <configuration> <verbose>true</verbose> <overwrite>true</overwrite> </configuration> </plugin> </plugins> </build>