提问者:小点点

使用STS 3.6.4的Spring示例


从Spring Tool Suite 3.6.4开始,我正在尝试开发一个Spring项目,我已经完成了所有事情,例如添加STS lib文件夹中存在的jar和apache公共日志记录1.1.3和1.2。

STS在新的ClassPathXmlApplicationContext("Beans. xml")的主类中显示错误;

当我试图解决它时,STS正在显示配置BuildPath我已经通过观看YouTube中的教程添加了所有的罐子。

我正在使用JAVA 1.6版本,OSUbuntu,STS 3.6.4下面列出的罐子我已经添加到buildpath

/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/aws-java-sdk-1.7.5.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/com.springsource.org.apache.commons.beanutils-1.8.3.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/com.springsource.org.apache.commons.cli-1.2.0.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/com.springsource.org.apache.commons.codec-1.5.0.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/com.springsource.org.apache.commons.collections-3.2.1.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/com.springsource.org.apache.commons.configuration-1.8.0.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/com.springsource.org.apache.commons.digester-1.8.1.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/com.springsource.org.apache.commons.jxpath-1.3.0.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/com.springsource.org.apache.commons.lang-2.6.0.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/com.springsource.org.apache.commons.logging-1.1.1.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/com.springsource.org.bouncycastle.jce-1.46.0.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/com.springsource.org.bouncycastle.mail-1.46.0.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/com.springsource.org.jdom-1.0.0.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/commons-codec-1.6.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/commons-logging-1.1.3.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/httpclient-4.3.3.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/httpcore-4.3.2.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/jackson-annotations-2.1.1.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/jackson-core-2.1.1.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/jackson-databind-2.1.1.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/joda-time-2.7.jar
/home/axxera/sts-bundle/pivotal-tc-server-developer-3.1.0.RELEASE/lib/tc-runtime-instance-3.1.0.RELEASE.jar
/home/axxera/Venkat/Libraries/org-apache-commons-logging.jar
/home/axxera/Venkat/Libraries/org.springframework.context-3.0.4.RELEASE.jar
/home/axxera/Venkat/Libraries/spring-context-4.1.5.RELEASE.jar
/home/axxera/Venkat/Libraries/jbehave-spring-3.6.4.jar
/home/axxera/Venkat/Libraries/commons-logging-1.2/commons-logging-1.2.jar
/home/axxera/Venkat/Libraries/commons-logging-1.2/commons-logging-1.2-javadoc.jar

下面是我的代码

主类

    package com.spring;

    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;

    public class Main {

        public static void main(String[] args) {

           ClassPathXmlApplicationContext appContext = 
                 new ClassPathXmlApplicationContext("Beans.xml");

       }

     }


    package com.spring;

    public class SpringSample {

       void printMessage() {

        System.out.println("Hello World");
       }
    }

豆子. xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans           http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="SampleBean" class="com.spring.SpringSample"></bean>

    </beans>

共1个答案

匿名用户

看来你错过了春豆-