我有一个Spring Boot多模块项目(投票一个基本的SpringBoot应用程序。使用Spring Initializer,嵌入式Tomcat,Thymeleaf模板引擎) 这里是父应用程序的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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.tdk-cloud</groupId>
<artifactId>tdk-cloud</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>tdk-core</module>
<module>tdk-batch</module>
<module>tdk-web</module>
</modules>
..
这里有一个库:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.tdk-cloud</groupId>
<artifactId>tdk-cloud</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.tdk.core</groupId>
<artifactId>tdk-core</artifactId>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
...
这里是另一个模块
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.tdk-cloud</groupId>
<artifactId>tdk-cloud</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.tdk.web</groupId>
<artifactId>tdk-web</artifactId>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.tdk.core</groupId>
<artifactId>tdk-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
...
但是当我在mvn spring-boot:run
模块中运行com.tdk.web
时,我收到了此错误:
[ERROR] Failed to execute goal on project tdk-web: Could not resolve dependencies for project com.tdkcloud.web:tdk-web:jar:0.0.1-SNAPSHOT: Could not find artifact com.tdkcloud.core:tdk-core:jar:0.0.1-SNAPSHOT -> [Help 1]
答案 0 :(得分:1)
错误清楚地说
Could not find artifact com.tdkcloud.core:tdk-core:jar:0.0.1-SNAPSHOT
首先构建tdk-core模块,使其在您的maven仓库中可用。
之后构建tdk-web模块。