英文:
read from spring xml
问题
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.context.annotation.ImportResource;
@SpringBootApplication
@EnableAutoConfiguration(exclude={file1.class, file2.class})
@ImportResource(locations = {"classpath*:applicationContext.xml"})
public class Trans{
public static void main(String[] args) {
SpringApplication.run(Trans.class, args);
}
}
当 XML 文件存在于 JAR 包中时,它可以正常工作并被读取。我希望将 XML 文件从 JAR 包中移动到机器上的现有文件夹中。但在这么做时,XML 文件无法被读取。如何从机器文件系统中读取 XML 文件而不是从 JAR 包中读取呢?
提前感谢您的回答!
英文:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.context.annotation.ImportResource;
@SpringBootApplication
@EnableAutoConfiguration(exclude={file1.class, file2.class})
@ImportResource(locations = {"classpath*:applicationContext.xml"})
public class Trans{
public static void main(String[] args) {
SpringApplication.run(Trans.class, args);
}
}
When the XML exist in the jar its working properly and the XML is read. I wish to remove the XML from the jar to an existing folder on the machine.
When doing it, the XML is not read. How can I read the XML from the machine file system and not from the jar?
Thanks in advance!
答案1
得分: 0
试试这个:
@ImportResource(locations = {"file:/some/resource/path/applicationContext.xml"})
英文:
Try this:
@ImportResource(locations = {"file:/some/resource/path/applicationContext.xml"})
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论