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

2021-11-17  本文已影响0人  GALAace

问题描述

有两个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>
上一篇 下一篇

猜你喜欢

热点阅读