一直這個錯誤:

------------------------------------------------- 下面的方法試了,不行。。。
明明就在一個包里面的類,引用的時候都出現了紅色錯誤,無法導入類。
或者其他的不可思議的錯誤。
可以試試“清除緩存重啟”:
第一步:菜單中選擇file->invalidate caches / restart

第二步:在彈出框中選擇Invalidate and Restart。idea關閉並且自動重啟,重啟后問題解決。

如果idea出現類似的不合邏輯的錯誤,很有可能是緩存導致,試試“清除緩存重啟”!
----------------------------------------------------- 后面終於發現問題, 原來是 maven的打包問題, thin jar 打包成了 fat jar
下面的 jar 的大小, 明顯不對, 怎么可能59M ? 明顯是 fat jar 的節奏

去掉 spring-boot-maven-plugin 就可以引入了!
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.4.2</version>
<!-- <version>${spring-boot.version}</version>-->
<configuration>
<mainClass>com.test.sad.JavaGateApplication</mainClass>
<jvmArguments>-Xms256M -Xmx1024M -XX:+UseConcMarkSweepGC</jvmArguments>
<executable>true</executable>
<includeSystemScope>true</includeSystemScope>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
或者修改打包時候的資源尋找位置:
<build>
<resources>
<!--mvn打包時,加入mvn外的jar包-->
<resource>
<directory>lib</directory>
<targetPath>BOOT-INF/lib</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
<resource>
<directory>src/main/java</directory>
<!--java文件中的xml文件允許打進包中,這部分是mybatis文件-->
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<!--這里打包的時候不打配置文件,因為這里的jar包僅供其他項目集成,應該在使用此jar的最外層加配置-->
<excludes>
<exclude>*.properties</exclude>
<exclude>*.xml</exclude>
</excludes>
</resource>
</resources>
...
通過 BOOT-INF/lib 就可以把 額外的jar 打包進來。
over !
