Java 从ant运行任务时,有没有办法从自定义文件夹添加hibernate.cfg.xml和log4j.properties文件

Java 从ant运行任务时,有没有办法从自定义文件夹添加hibernate.cfg.xml和log4j.properties文件,java,hibernate,ant,log4j,Java,Hibernate,Ant,Log4j,我正在使用ANT运行我的项目,我的hibernate.cfg.xml和log4j.properties文件位于一个名为/config的自定义文件夹下,当我从ANT运行任务时,由于找不到hibernate.cfg.xml而失败,并显示log4j appenders警告。无论如何都可以让ant在自定义文件夹下查找这些文件,而不是将其放在src下 目标名称- <target name="controlGRID" depends="compile">

我正在使用ANT运行我的项目,我的hibernate.cfg.xml和log4j.properties文件位于一个名为/config的自定义文件夹下,当我从ANT运行任务时,由于找不到hibernate.cfg.xml而失败,并显示log4j appenders警告。无论如何都可以让ant在自定义文件夹下查找这些文件,而不是将其放在src下

目标名称-

 <target name="controlGRID" depends="compile">
                    <echo>
                Please wait .... GRID is starting up...
                </echo>
                    <java classname="foo.bar.framework.selenium.SetupGrid" classpath="${test.dest}" classpathref="test.c">
                    <arg value="${arg}"/>
                    </java>
                    <echo>
                    GRID Start up complete !
                </echo>
                </target>

我研究了我的hibernate类并找到了解决方案:

hibernateConfig = new Configuration();
        hibernateConfig.configure (new File(System.getProperty("user.dir")+"/config/hibernate.cfg.xml"));
        StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder().applySettings(hibernateConfig.getProperties());
        hibernateSessionFactory = hibernateConfig.buildSessionFactory(ssrb.build());
这里早些时候我的代码是-

hibernateConfig.configure();
我把它改成了-

hibernateConfig.configure (new File(System.getProperty("user.dir")+"/config/hibernate.cfg.xml"));

我找到了我的答案,我希望它也能帮助其他人。

你能展示一个你正在尝试运行的ANT任务示例吗?请提供你认为有助于回答这个问题的ANT文件部分。@dg99-我已经编辑并添加了有问题的示例。thanks@bot我已经添加了有关ant文件的部分
hibernateConfig.configure();
hibernateConfig.configure (new File(System.getProperty("user.dir")+"/config/hibernate.cfg.xml"));