idea 报错java程序包不存在,找不到符号

问题描述

img
idea版本: 2020.1.1. 程序代码是正确的, 之前是可以运行的. 现install可以, 但运行或debug时会报这样的错误

解决方法

不要修改maven的仓库存储位置(settings.xml中的localRepository值不要设置). 使用默认值.
img

原理分析

项目下.idea/libraries目录下会记录当前项目使用的jar包的路径.
img
$MAVEN_REPOSITORY$代表仓库的目录. settings.xml中的localRepository值. 但当你修改设置localRepository值为其他目录时, 这里好像还是指向旧的仓库目录.

其他解决方法

  • 方法1: 修改当前项目的maven仓库位置
    img
    注: 这里设置只会影响到当前项目(这个会记录在项目下.idea/workspace.xml中). 项目中的jar包会重新下载, 浪费空间.

  • 方法2: Setting-maven-running 中勾选上 Delegate IDE build/run actions to Maven
    img

教程: https://blog.csdn.net/lililidahaoren/article/details/126404841

posted @ 2023-03-29 13:48  陈同学  阅读(495)  评论(0编辑  收藏  举报