美文网首页
Maven install打包无法被依赖,报错Cannot re

Maven install打包无法被依赖,报错Cannot re

作者: GALAace | 来源:发表于2021-11-17 14:39 被阅读0次

问题描述

有两个SpringBoot项目,demo1和demo2,demo2需要依赖demo1,在demo1项目中使用mvm install后,在demo2的pom.xml文件中引入damo1的groupId,artifactId,version信息后,可以在External Libraries中找的,但是在代码中使用demo1中的类时,idea显示Cannot resolve symbol 'xxx'

问题原因

springboot项目中maven默认配置打的jar包是不可依赖的,即使依赖了也不可使用

解决办法

将demo1的pom.xml文件中的

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

替换为

<build>
      <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <configuration>
                  <source>1.8</source>
                  <target>1.8</target>
              </configuration>
          </plugin>
      </plugins>
 </build>

相关文章

网友评论

      本文标题:Maven install打包无法被依赖,报错Cannot re

      本文链接:https://www.haomeiwen.com/subject/ixvltrtx.html