【问题标题】:SpringSource building a sample programSpringSource 构建示例程序
【发布时间】:2010-07-30 08:12:59
【问题描述】:

我刚开始学习 Java,但遇到了一些简单的问题。 建议我使用 Spring 框架,为此我下载了 SpringSource Tool Suite 安装程序,双击并安装它。

当我运行简单的 hello world 应用程序时,它可以工作。但是当我尝试使用其中一个 spring 框架的类时,我得到了错误“线程主 java.lang.NoClassDefFoundError 中的异常:org/apache/commons/logging/LogFactory ...”

当我单击查看发生错误的行时,我得到“JAR 文件...没有源附件。”

来源在哪里?

我的代码:

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;
import JavaBeanTest.Person;

public class ClassMain {

public static void main(String args[]) throws ClassNotFoundException {


try {
 FileSystemResource resource = new FileSystemResource("c:/Person.xml");
 BeanFactory factory = new XmlBeanFactory(resource);
 Person person = (Person) factory.getBean("Person");

 person.PrintName();
} catch (Exception err) {
 System.out.println("mehmet");
 System.out.println(err.getMessage());

}

}
}

我真的很感激任何帮助...

【问题讨论】:

    标签: java eclipse spring sts-springsourcetoolsuite


    【解决方案1】:

    我不确定您是否仍然遇到此问题,但我会查看您的 java 构建路径以确保包含 commons-logging jar。它是您的项目直接需要的,因此您不会遇到编译时问题。

    如果你把你的 .classpath 文件贴在这里,我可以看看。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-02
      • 2015-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多