J
Javalia
Gast
Hallo,
ich möchte gerne die Spring-Bibliotheken für ein Projekt nutzen. Bislang stand im Ant-File das hier:
Und alles hat auch fein kompiliert und wurde ausgeführt. Jetzt habe ich mein Projekt erweitert und möchte in einer Klasse das hier importieren:
Dazu habe ich Spring 2.0.2 heruntergeladen und folgende Dateistruktur erstellt:
RentABike (Projekt)
-- bin
-- db
-- src (die Java-Files)
-- test
-- war
build.xml (mein Ant-File)
In war ist:
war
-- classes
-- WEB-INF
-- -- lib
-- -- -- modules (Hier sind die Spring-Jars)
Die Spring-Jars hab ich jetzt auch über Project --> Library --> Add Jars hinzugefügt und ich kann im Editor zB Autocompletion nutzen und bekomme die org.springframework... angezeigt.
Warnings gibt's nicht. Aber wenn ich jetzt das Ant-File durchlaufen lasse, krieg ich Compiler-Errors:
Kann es sein, dass ich was im build.xml ändern muss? Hatte an sowas gedacht:
Bringt aber leider auch keine positive Veränderung. Hat vielleicht jemand einen Tipp für mich?
ich möchte gerne die Spring-Bibliotheken für ein Projekt nutzen. Bislang stand im Ant-File das hier:
Code:
<?xml version="1.0"?>
<project name="RentABike" default="compile" basedir=".">
<property name="src.dir" value="src" />
<property name="test.dir" value="test" />
<property name="war.dir" value="war" />
<property name="class.dir" value="${war.dir}/classes" />
<target name="init" >
<mkdir dir="${class.dir}" />
</target>
<target name="compile" depends="init" description="Compiles all Source Code">
<javac srcdir="${src.dir}" destdir="${class.dir}" />
</target>
<target name="clean" description="Erases content of class directory">
<delete dir="${class.dir}" />
</target>
</project>
Code:
import org.springframework.context.support.*;
RentABike (Projekt)
-- bin
-- db
-- src (die Java-Files)
-- test
-- war
build.xml (mein Ant-File)
In war ist:
war
-- classes
-- WEB-INF
-- -- lib
-- -- -- modules (Hier sind die Spring-Jars)
Die Spring-Jars hab ich jetzt auch über Project --> Library --> Add Jars hinzugefügt und ich kann im Editor zB Autocompletion nutzen und bekomme die org.springframework... angezeigt.
Warnings gibt's nicht. Aber wenn ich jetzt das Ant-File durchlaufen lasse, krieg ich Compiler-Errors:
Code:
Buildfile: /Users/javalia/Projekte/RentABike/build.xml
init:
compile:
[javac] Compiling 2 source files to /Users/javalia/Projekte/RentABike/war/classes
[javac] /Users/javalia/Projekte/RentABike/src/com/springbook/RentABikeAssembler.java:3: package org.springframework.context.support does not exist
[javac] import org.springframework.context.support.*;
[javac] ^
[javac] /Users/javalia/Projekte/RentABike/src/com/springbook/RentABikeAssembler.java:10: cannot find symbol
[javac] symbol : class ClassPathXmlApplicationContext
[javac] location: class com.springbook.RentABikeAssembler
[javac] ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext ("RentABike-context.xml");
[javac] ^
[javac] /Users/javalia/Projekte/RentABike/src/com/springbook/RentABikeAssembler.java:10: cannot find symbol
[javac] symbol : class ClassPathXmlApplicationContext
[javac] location: class com.springbook.RentABikeAssembler
[javac] ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext ("RentABike-context.xml");
[javac] ^
[javac] 3 errors
BUILD FAILED
/Users/javalia/Projekte/RentABike/build.xml:16: Compile failed; see the compiler error output for details.
Total time: 1 second
Kann es sein, dass ich was im build.xml ändern muss? Hatte an sowas gedacht:
Code:
<property name="spring.dir" value="${war.dir}/WEB-INF/modules" />
...
<target name="compile" depends="init" description="Compiles all Source Code">
<javac srcdir="${src.dir}" destdir="${class.dir}">
<classpath>
<pathelement location="${spring.dir}/"/>
</classpath>
</javac>
</target>
Bringt aber leider auch keine positive Veränderung. Hat vielleicht jemand einen Tipp für mich?