我是 Spring 新手,目前正在尝试ProSpring3 书中的以下Hello World 示例:
package com.tutorials.prospring3.ch2;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class HelloWorldSpringDI {
public static void main(String[] args) {
// Initialize Spring ApplicationContext
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"META-INF/spring/app-context.xml");
MessageRenderer mr = ctx.getBean("renderer", MessageRenderer.class);
mr.render();
}
}
ClassPathXmlApplicationContext 实例化被标记为以下错误:“构造函数 ClassPathXmlApplicationContext(String) 引用缺少的类型 BeansException”
此外,在运行应用程序时,IDE 会显示构建路径问题: “Archive for required library: 'C:/Users/Admin/.m2/repository/org/springframework/spring-beans/3.0.6.RELEASE/spring-项目 'ch2' 中的 beans-3.0.6.RELEASE.jar' 无法读取或不是有效的 ZIP 文件”
由于 spring-beans.jar(BeansException 类所属的)是我的Maven 依赖项的一部分,我想知道这是怎么发生的。
有没有人建议如何解决这个问题?
提前致谢!
乔纳斯