首页 > 解决方案 > 在 Intellij Ultimate 中为简单的 Spring 应用程序设置 applicationContext.xml

问题描述

我是 Spring 的新手,我正在尝试设置一个简单的 Spring 应用程序,我正在通过在线教程进行学习。然而,导师正在使用 Eclipse,而 IntelliJ 正在抱怨

Cannot find the declaration of element 'beans'. 

....来自 applicationContext.xml

我唯一的 Spring POM 依赖项:

    <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-core</artifactId>
       <version>5.1.9.RELEASE</version>
    </dependency>

我的 applicationContext.xml

在此处输入图像描述

我是否必须从项目结构中的“构面”上下文菜单中进行设置?如果是这样,怎么做?

我拥有典型 Ultimate 安装中捆绑的所有标准 Spring 插件:

在此处输入图像描述

我的项目结构:

在此处输入图像描述

标签: javaspringintellij-idea

解决方案


除了 Spring Core,您还必须对 Spring Beans 使用以下依赖项。

<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>5.1.9.RELEASE</version>
</dependency>

推荐阅读