在Spring Boot项目中找不到依赖项 [英] Dependency not found in Spring Boot project

查看:2027
本文介绍了在Spring Boot项目中找不到依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在projectA中执行 mvn clean compile 时,我得到包不存在编译错误。错误是指从projectB导入的包,它是一个Spring Boot项目(projectA是一个常规的maven项目)。 projectB很好地编译,生成的jar在我当地的maven仓库中。



projectB包含在projectA中:

 < projectB.version> 1.0.4-SNAPSHOT< /projectB.version> 

[...]

< dependency>
< groupId> de.company< / groupId>
< artifactId> projectB< / artifactId>
< version> $ {projectB.version}< / version>
< / dependency>

我已经进行了常规清理,并且还手动删除了projectB的本地仓库的内容。

解决方案

我没有使用重新打包目标,但是从



$ b <$ p后$ p> < plugin>
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-maven-plugin< / artifactId>
< / plugin>

 < plugin> 
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-maven-plugin< / artifactId>
< executions>
< execution>
< goals>
< goal> repackage< / goal>
< / goals>
< configuration>
< classifier> exec< / classifier>
< / configuration>
< / execution>
< / executions>
< / plugin>

......它有效。


When doing a mvn clean compile in projectA I'm getting a package does not exist compilation error. The error is refering to a package imported from projectB, which is a Spring Boot project (projectA is a regular maven project). projectB compiles nicely and the resulting jar is in my local maven repo.

projectB is included in projectA:

    <projectB.version>1.0.4-SNAPSHOT</projectB.version>

    [...]

    <dependency>
        <groupId>de.company</groupId>
        <artifactId>projectB</artifactId>
        <version>${projectB.version}</version>
    </dependency>

I already did the usual cleaning and also deleted the contents of the local repo for projectB manually.

解决方案

I did not use the repackage goal, but after going from

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

to

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                    <configuration>
                        <classifier>exec</classifier>
                    </configuration>
                </execution>
            </executions>
        </plugin>

...it worked.

这篇关于在Spring Boot项目中找不到依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆