我创建了一个本地 Maven 存储库并在那里部署了一个自己的库:使用:
mvn clean package install deploy
上:
http://maven.apache.org/xsd/maven-4.0.0.xsd">4.0.0
<groupId>de.example</groupId>
<artifactId>example-lib</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>example-lib</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-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</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>
<distributionManagement>
<repository>
<id>example.repo</id>
<name>example internal mvn repository</name>
<url>file://${project.basedir}/../mvn-repo</url>
</repository>
</distributionManagement>
现在另一个项目使用它:
<repositories>
<repository>
<id>example.repo</id>
<url>file://${project.basedir}/../mvn-repo</url>
</repository>
</repositories>
...
<dependency>
<groupId>de.example</groupId>
<artifactId>example-lib</artifactId>
<version>0.0.1</version>
</dependency>
...
但是在编译项目时,lib中的所有符号都丢失了(但是依赖关系已解决,并且.jar文件在那里)
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/gregor/Documents/dev/repo/example/core/src/main/java/de/example/core/CoreApplication.java:[11,31] package de.example.examplelib does not exist
[ERROR] /C:/Users/gregor/Documents/dev/repo/example/core/src/main/java/de/example/core/DbExampleService.java:[11,42] package de.example.examplelib.db.example does not exist
[ERROR] /C:/Users/gregor/Documents/dev/repo/example/core/src/main/java/de/example/core/DbExampleService.java:[12,42] package de.example.examplelib.db.example does not exist
[ERROR] /C:/Users/gregor/Documents/dev/repo/example/core/src/main/java/de/example/core/DbExampleService.java:[19,17] cannot find symbol
symbol: class UserRepository
location: class de.example.core.DbExampleService
[ERROR] /C:/Users/gregor/Documents/dev/repo/example/core/src/main/java/de/example/core/DbExampleService.java:[35,39] cannot find symbol
symbol: class User
location: class de.example.core.DbExampleService
我已经搜索了最后 4 个小时,也许我只是错过了一些基本的东西?打开提示。提前致谢。