Maven打包包含本地jar包并同时打入到打包文件中pom配置详解 首先引入本地文件的jar包以及jar路径地址 //引入本地jar包地址 <dependency> <groupId>j-interop</groupId> <artifactId>j-interop</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>${project.basedir}/lib/j-interop.jar</systemPath> </dependency> <dependency> <groupId>j-interopdeps</groupId> <artifactId>j-interopdeps</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>${project.basedir}/lib/j-interopdeps.jar</systemPath> </dependency> <dependency> <groupId>jcifs-1.2.19</groupId> <artifactId>jcifs-1.2.19</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>${project.basedir}/lib/jcifs-1.2.19.jar</systemPath> </dependency> <dependency> <groupId>org.openscada.opc.dcom_1.1.0.v20130529</groupId> <artifactId>org.openscada.opc.dcom_1.1.0.v20130529</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>${project.basedir}/lib/org.openscada.opc.dcom_1.1.0.v20130529.jar</systemPath> </dependency> <dependency> <groupId>org.openscada.opc.lib_1.1.0.v20130529</groupId> <artifactId>org.openscada.opc.lib_1.1.0.v20130529</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>${project.basedir}/lib/org.openscada.opc.lib_1.1.0.v20130529.jar</systemPath> </dependency> 1234567891011121314151617181920212223242526272829303132333435 然后配置加载resource文件及打包后加载文件搜索目录
<build> <resources>#配置文件加载的路径及读取 <resource>#读取本地jar包打包路径 <directory>lib</directory> <targetPath>BOOT-INF/lib/</targetPath> <includes> <include>**/*.jar</include> </includes> </resource> <!--第一种加载所有文件--> <resource>#读取resource文件夹下的所有文件 <directory>src/main/resources</directory> <includes> <include>**/*.*</include> </includes> </resource> <!--第二种加载指定文件--> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.txt</include> <include>**/*.yml</include> </includes> <filtering>false</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <includeSystemScope>true</includeSystemScope> #文件打包时同时打进jar包 </configuration> </plugin> <!--忽略测试启动类--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>${maven-surefire-plugin.version}</version> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> </build> ---------------------