午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術文章
文章詳情頁

java - spring boot多模塊項目如打包?

瀏覽:181日期:2023-11-16 09:15:45

問題描述

我構建了一個簡單的多模塊的項目: 結構:java - spring boot多模塊項目如打包?

外層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/xsd/maven-4.0.0.xsd'><modelVersion>4.0.0</modelVersion><groupId>com.scum</groupId><artifactId>demo-package</artifactId><version>1.0-SNAPSHOT</version><packaging>pom</packaging><modules> <module>demo-controller</module> <module>demo-service</module></modules><build> <plugins><plugin> <!-- The plugin rewrites your manifest --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId><configuration><!-- 指定該Main Class為全局的唯一入口 --> <mainClass>com.example.demo.DemoControllerApplication</mainClass> <layout>ZIP</layout></configuration><executions> <execution><goals> <goal>repackage</goal><!--可以把依賴的包都打包到生成的Jar包中--></goals><!--可以生成不含依賴包的不可執行Jar包--><!-- configuration> <classifier>exec</classifier></configuration> --> </execution></executions> </plugin></plugins>

</build>

</project>

`web pom文件`<?xml version='1.0' encoding='UTF-8'?><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/xsd/maven-4.0.0.xsd'><modelVersion>4.0.0</modelVersion><groupId>com.example</groupId><artifactId>demo-controller</artifactId><version>0.0.1-SNAPSHOT</version><packaging>jar</packaging><name>demo-controller</name><description>Demo project for Spring Boot</description><parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.3.RELEASE</version> <relativePath/> <!-- lookup parent from repository --></parent><properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version></properties><dependencies> <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope> </dependency></dependencies><build> <plugins><plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId></plugin> </plugins></build>

</project>`

能運行 打包報IndexService 不存在

package com.example.demo;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;@SpringBootApplication@Controllerpublic class DemoControllerApplication { @Autowired private IndexService indexService; public static void main(String[] args) {SpringApplication.run(DemoControllerApplication.class, args); } @RequestMapping(value = '') @ResponseBody public String index(){return indexService.Index(); }}

問題解答

回答1:

這不是Spring-boot的問題,這是Maven依賴的問題

假設我有一個maven工程是醬紫的

尖括號是工程類型,前面是工程層級

iot-cloud<pom>

iot-http<jar>iot-mqtt<jar>iot-oauth<jar>iot-sql-service<jar>iot-restful<war>

iot-cloud總工程下有5個子工程,其中iot-restful是入口工程,也就是Spring-boot的啟動工程,它依賴其他四個工程來提供服務,那么你就在iot-resutful中引入其它四個作為dependency,然后maven install就好了

當然啦,測試用例不打包,配置文件引入優先級還是要考慮的

iot-restful的pom.xml<dependencies><dependency> <groupId>pri.somnus</groupId> <artifactId>iot-http</artifactId> <version>0.0.1-SNAPSHOT</version></dependency><dependency> <groupId>pri.somnus</groupId> <artifactId>iot-http</artifactId> <version>0.0.1-SNAPSHOT</version></dependency><dependency> <groupId>pri.somnus</groupId> <artifactId>iot-mqtt</artifactId> <version>0.0.1-SNAPSHOT</version></dependency><dependency> <groupId>pri.somnus</groupId> <artifactId>iot-oauth</artifactId> <version>0.0.1-SNAPSHOT</version></dependency><dependency> <groupId>pri.somnus</groupId> <artifactId>iot-sql-service</artifactId> <version>0.0.1-SNAPSHOT</version></dependency> </dependencies>

標簽: java
相關文章:
主站蜘蛛池模板: 国产人成一区二区三区影院 | 在线观看黄 | xxxxxx国产| 精品国产大片大片大片 | 成人在线视频免费观看 | 热久久国产精品 | 欧美精品久久久久久久久老牛影院 | 免费a在线 | 欧美中文日韩 | 国产又黄又硬 | 在线观看视频你懂的 | 欧美亚洲精品在线 | 91精品欧美 | 97人人澡| 视频一区二区中文字幕 | 日韩高清国产一区在线 | 婷婷在线影院 | 六月婷婷激情 | 狠狠操综合 | 在线免费日韩av | 亚洲青涩在线 | 亚洲色图欧美视频 | 亚洲精品五月天 | 97久久久 | 欧美黄色片免费看 | 69性视频| 蜜桃五月天 | 欧洲中文字幕 | 在线观看视频一区 | 亚洲最新中文字幕 | 这里只有精品9 | 久久人人精品 | 亚洲第一区在线 | 午夜精品三级久久久有码 | 久久国产精品免费观看 | 在线免费观看国产精品 | 日本黄色www| 一区二区三区在线视频播放 | 免费在线观看黄网站 | 成人免费黄 | 亚洲最大视频网站 |