Ant -verbose 失败并显示“包不存在”尽管 jar 位于类路径上
我有以下代码
package myPackage;
import org.neo4j.graphdb;
import org.neo4j.kernel.EmbeddedGraphDatabase;
public class dbServlet extends HttpServlet {
public void init() throws ServletException {
// Start up the database here
GraphDatabaseService graphDb = new EmbeddedGraphDatabase("var/base");
}
public void destroy() {
graphDb.shutdown();
}
和 build.xml 文件:
<project name="dbServlet" basedir="." default="compile">
<property name="src.dir" value="src"/>
<property name="lib.dir" value="lib"/>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/jar"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
</target>
</project>
所有 neo4j jar 都位于 build.xml 文件所在的 lib 目录中。源代码位于 src/myPackage/dbServlet.java。当我运行 ant -v 时,类路径包含具有 neo4j 类的 jar,但 javac 说这些包不存在。有人知道为什么会这样吗?
下面是错误的片段(我现在关心的是第一个错误,我知道 servlet api 尚未在路径上):
[javac] /home/shaun/projects/helloAnt/src/myPackage/dbServlet.java:3: package org.neo4j does not exist
[javac] import org.neo4j.graphdb;
[javac] ^
[javac] /home/shaun/projects/helloAnt/src/myPackage/dbServlet.java:6: cannot find symbol
[javac] symbol: class HttpServlet
[javac] public class dbServlet extends HttpServlet {
[javac] ^
[javac] /home/shaun/projects/helloAnt/src/myPackage/dbServlet.java:8: cannot find symbol
[javac] symbol : class ServletException
[javac] location: class myPackage.dbServlet
[javac] public void init() throws ServletException {
[javac] ^
I have the following code
package myPackage;
import org.neo4j.graphdb;
import org.neo4j.kernel.EmbeddedGraphDatabase;
public class dbServlet extends HttpServlet {
public void init() throws ServletException {
// Start up the database here
GraphDatabaseService graphDb = new EmbeddedGraphDatabase("var/base");
}
public void destroy() {
graphDb.shutdown();
}
and build.xml file:
<project name="dbServlet" basedir="." default="compile">
<property name="src.dir" value="src"/>
<property name="lib.dir" value="lib"/>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/jar"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
</target>
</project>
All of the neo4j jars are located in a lib directory where the build.xml file is. The source is located at src/myPackage/dbServlet.java. When I run ant -v, the classpath includes the jars that have the neo4j classes, but javac is saying the packages don't exist. Anyone know why this could be?
Heres a snippet of the errors (I'm concerned with the first one for now, I know that the servlet api's aren't on the path yet):
[javac] /home/shaun/projects/helloAnt/src/myPackage/dbServlet.java:3: package org.neo4j does not exist
[javac] import org.neo4j.graphdb;
[javac] ^
[javac] /home/shaun/projects/helloAnt/src/myPackage/dbServlet.java:6: cannot find symbol
[javac] symbol: class HttpServlet
[javac] public class dbServlet extends HttpServlet {
[javac] ^
[javac] /home/shaun/projects/helloAnt/src/myPackage/dbServlet.java:8: cannot find symbol
[javac] symbol : class ServletException
[javac] location: class myPackage.dbServlet
[javac] public void init() throws ServletException {
[javac] ^
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,您的导入不太正确 - 您想导入 org.neo4j.graphdb 包中的所有类吗?
否则你应该给出一个特定的类名。 javac 错误消息表明正在寻找包 org.neo4j - graphdb 被视为类名。
It looks to me like your import is not quite right - do you want to import all the classes in the
org.neo4j.graphdb
package?Else you should give a specific class name. The javac error message indicates that a package
org.neo4j
is being sought - graphdb is being treated as a class name.