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號