1
我想将Spring IOC添加到基于Maven的Swing应用程序框架项目中。所以我加入到pom.xml的依赖关系:NetBeans:将Spring IOC添加到基于Maven的Swing应用程序框架项目
<!-- 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()initializated的ApplicationContext:
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.scan("com.mypackagewithbeans");
ctx.refresh();
launch(DesktopApplication1.class, args);
}
但我不能建项目,因为IDE看不到春天的图书馆都没有。我试图删除<scope>runtime</scope>
行,但它不能解决问题(IDE无法看到注释,例如@Autowire)。
我应该怎么做才能将NetBeans Swing应用程序框架项目(使用maven)添加到Spring IOC支持?
我需要在pom.xml中'运行 '?我阅读http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/overview.html#d0e679,但它不适用于范围... –
2010-02-09 09:47:13
您应该使用范围编译因为您正在使用@AutoWired注解。 – 2010-02-09 11:22:52