Error:(4, 35) java: 程序包org.springframework.context不存在 解决问题的方法

public class APP {
    
    
    public static void main(String[] args) {
    
    
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
        Person ps = (Person) ac.getBean("p");
        ps.save();
    }
}

问题描述:

Error:(4, 35) java: 程序包org.springframework.context不存在;

**

解决方案:

要把maven配置文件settings.xml中自己加的本地下载位置删除, 如果想改位置,就在idea手动修改本地仓库的配置。
找到自己电脑的Maven文件下的配置文件settings.xml
D:\Program Files\Maven\apache-maven-3.6.0\conf\settings.xml
在这里插入图片描述
在这里插入图片描述

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!--   删除自己添加的 localRepository 地址  -->
<!--  <localRepository>F:\Program Files\Maven\Maven下jar包库</localRepository>-->

可以用idea清空缓存,重建索引在这里插入图片描述
然后刷新maven项目,问题解决!

猜你喜欢

转载自blog.csdn.net/yi_HelloC/article/details/111301807