【问题标题】:Content Assist not working in applicationContext.xml with Java Project with 'Spring Project Nature' in eclipseEclipse 中带有“Spring Project Nature”的 Java 项目中的 Content Assist 无法在 applicationContext.xml 中工作
【发布时间】:2011-03-27 20:12:53
【问题描述】:
我有一个使用 Spring 3 和 Hibernate 3 的简单 Java 项目。
我使用 Spring IDE 添加了“Spring Project Nature”。 applicationContext.xml 文件位于项目的 src 文件夹中。
Eclipse 3.5 的内容辅助功能似乎在 applicationContext.xml 中不起作用:
- 在 bean 标签的 class 属性中,似乎在我的 Java 项目中找不到包和类。
- 它无法帮助处理任何属性,例如在 applicationContext.xml 中为 ref 属性查找现有 bean。
【问题讨论】:
标签:
eclipse
spring
spring-ide
【解决方案1】:
- Project Properties > Spring > Bean Support > Config Sets > Add New Group(包含所有配置文件)。然后再次打开 applicationContext.xml。
- 如果内容辅助不起作用,请尝试使用 Spring Config Editor 打开相关文件。
-
如果第 1 步中的 Project Properties > Spring 不存在,请安装:
- SpringSource 工具套件:核心/STS > SpringSource 工具套件(必需)
- 如有需要,可进行附加扩展,例如AOP、Autowire、安全性。
【解决方案2】:
Spring IDE 和 STS 仅在类或相应属性中至少键入一个字符后才能完成 Java 类和包名称。
如果您想通过 XML 文件的名称获取 Bean 引用的内容辅助,您需要定义一个配置集(项目属性 > Spring > Bean 支持 > 配置集)。
【解决方案3】:
要在 Eclipse 中为 spring 项目启用内容辅助,
进入 Projects->Properties->Spring->Config Detection 并选择自动检测的所有选项。