VenkatKrishna
VenkatKrishna

Reputation: 127

Spring Example using STS 3.6.4

From Spring Tool Suite 3.6.4 I am trying develop a Spring project I have done every thing like adding jars present in the STS lib folder and apache common-logging 1.1.3 and 1.2.

STS is showing error in main class at new ClassPathXmlApplicationContext("Beans.xml");

while I am trying to solve it, STS is showing configure BuildPath I have added all the jars by watching the tutorials in Youtube.

I am using JAVA 1.6 version, OS Ubuntu, STS 3.6.4 Below listed jars I have added to 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

Below is my code

Main Class

    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");
       }
    }

Beans.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>

Upvotes: 0

Views: 555

Answers (1)

Jens
Jens

Reputation: 69440

Looks like you miss the spring-beans-<version>.jar. Download it and add it to your classpath.

Upvotes: 2

Related Questions