【发布时间】:2018-09-28 21:45:15
【问题描述】:
我创建了一个 XML 属性文件,其中包含如下 sql 查询:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="sample.select">
<![CDATA[
The SQL query goes here
]]>
</entry>
</properties>
在我的 DAO 中,我想获取属性“sample.select”,但我不知道在 Spring Boot 中这是如何完成的,当我搜索它时,我发现我必须添加注释 @ImportResource("classpath:my-file.xml") 到Application 类,但我想读取 DAO 类中的资源文件,而不是 Application 类。
我该如何解决这个问题?
【问题讨论】:
标签: java spring-boot