java - 从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);
}
}
当 jar 中存在 XML 时,它可以正常工作并读取 XML。我希望将 XML 从 jar 中删除到机器上的现有文件夹中。执行此操作时,不会读取 XML。如何从机器文件系统而不是 jar 中读取 XML?
提前致谢!
解决方案
尝试这个:
@ImportResource(locations = {"file:/some/resource/path/applicationContext.xml"})
推荐阅读
- llvm - 选择与 irtranslator 通行证崩溃
- javascript - 如何使页面仅在使用 express 和 ejs 登录时才可访问
- spark-ar-studio - Spark AR Studio:是否可以从脚本中获取屏幕像素的颜色?
- c - 我手动制作的 .tga 文件有什么问题?
- apache-kafka - 使用 --bootstrap-server 创建 Kafka 主题给出超时异常(kafka 版本 2.5)
- visual-studio-2015 - 加载数据库信息失败:SAP Crystal Reports ActiveX Designer
- ruby-on-rails - 表单提交后下拉选择菜单重置为默认选项选择
- php - setcookie() 不设置 cookie
- css - Element UI - VueJS - 在 IOS 上选择输入双击错误
- graph - 查找所有拓扑顺序