【发布时间】:2010-02-08 15:58:06
【问题描述】:
我想将 spring IOC 添加到基于 maven 的 Swing 应用程序框架项目。于是我在 pom.xml 中添加了依赖:
<!-- Spring IOC -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.0.RELEASE</version>
<scope>runtime</scope>
</dependency>
<!-- log4j for Spring -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<scope>runtime</scope>
</dependency>
并在main()中初始化ApplicationContext:
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.scan("com.mypackagewithbeans");
ctx.refresh();
launch(DesktopApplication1.class, args);
}
但我无法构建项目,因为 IDE 根本看不到 spring 库。我试图删除<scope>runtime</scope>这一行,但它并没有解决问题(IDE看不到注释,例如@Autowire)。
如何将 Spring IOC 支持添加到 NetBeans Swing 应用程序框架项目(使用 maven)?
【问题讨论】: