首先打开 项目B 的 pom 文件,加入以下配置html
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build>
不要使用 以下配置,这样打成的包引用时会有问题spring
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin>
第二步把项目B的包导入项目Aapache
不懂的能够百度maven导入本地jar包maven
<dependency> <groupId>online</groupId> <artifactId>html</artifactId> <scope>system</scope> <systemPath>${basedir}/src/main/resources/lib/html-0.0.1-SNAPSHOT.jar</systemPath> </dependency>
如此就能够在项目A中引用项目B的类了编辑器
可是若是你的项目B依赖了额外的jar包,记得在项目A中也引用一下。spring-boot
固然咱们也能够在B项目打包的时候把依赖包一并打包进来。在maven中加入额外插件 配置以下ui
<plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>online.html.HtmlApplication</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin>
经过编辑器中maven管理,单击以下按钮插件
最终 jar 包以下 XXX-with-dependencies.jarhtm