1、在当前项目中创建lib目录,放入第三方jar包

2、在pom文件中引入jar包
<dependency>
<groupId>com.myjar</groupId>
<artifactId>com.myjar</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/myjar.jar</systemPath>
</dependency>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- 引入外部jar包,打包时需要设置的 -->
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
3、在启动类中以注解的形式将jar中的mapper、service、controller注入到当前项目的spring容器中
@SpringBootApplication
//将myjar的dao到本项目中,如果myjar,xml位置不是com.example.demo01.dao,需要在配置文件中指明路径
//demo01是myjar中的,demo02是当前项目
@MapperScan({"com.example.demo01.dao","com.example.demo02.dao"})
//将myjar的service、controller注入到本项目中
@ComponentScan({"com.example.demo01.service","com.example.demo02"})
public class Demo02Application {
public static void main(String[] args) {
SpringApplication.run(Demo02Application.class, args);
}
}
浙公网安备 33010602011771号