1.引言
最近準(zhǔn)備做一個(gè)開源項(xiàng)目。沒得人寫app接口,無奈我只有零時(shí)充當(dāng)后臺(tái)人員 了。因?yàn)橐郧坝眠^Spring boot,感覺這個(gè)框架很不錯(cuò),快速搭建起項(xiàng)目。于是選用它作為后臺(tái)開發(fā)框架。下面就把自己這幾天遇到的大大小小的坑說下。百度了很多都沒找到。
2.正題
項(xiàng)目的結(jié)構(gòu):

Paste_Image.png
rent:是一個(gè)project,創(chuàng)建的方式。

Paste_Image.png
rentModel,rentApp,rentCms 都是rent下面的 module依賴。其中rentApp,rentCms 都依賴rentModel。
rentApp的 pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>rent</artifactId>
<groupId>com.xinyi</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>rentApp</artifactId>
<packaging>jar</packaging>
<name>rentApp Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.xinyi</groupId>
<artifactId>rentModel</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.5.RELEASE</version>
</dependency>
</dependencies>
<!--<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>-->
</plugin>
</plugins>
</build>
</project>
pom.xml 已經(jīng)添加了rentModel 依賴了。。
問題1.
通過maven spring-boot:start運(yùn)行rentApp的時(shí)候 老提示,找不到rentModel 模塊。奇怪的是以Application啟動(dòng),能運(yùn)行。。
解決:
先clean,rentApp,在build rentApp。。這樣的問題一般都是maven構(gòu)建的問題。不斷的去clean,rebuild。
問題2.
項(xiàng)目打包的時(shí)候,在服務(wù)器上運(yùn)行,有提示找不到rentModule 里面的類,找不到里面的方法。。
解決:
先clean rentModel,然后編譯rentModel。然后打包rentModel,然后上傳到本地倉庫。最后在打包rentApp 就ok了。
以上的打包,編譯全部都是 通過maven 實(shí)現(xiàn)的

Paste_Image.png
以上就是我在搭建多模塊的spring boot項(xiàng)目 遇到的問題。。折騰了 百度了很多都沒找到靠譜的方案。