我有一些示例代碼在它不能找到資源文件夾中的SpringBeans.groovy,但我可以找到log4j.properties - 任何想法爲什麼它不會找到文件?
static main(args) {
// Load the spring beans
BeanBuilder beanBuilder = new BeanBuilder()
//beanBuilder.loadBeans("classpath:SpringBeans.groovy")
beanBuilder.loadBeans("file:src/main/resources/SpringBeans.groovy")
def res = new ClassPathResource ("log4j.properties")
File fprop = res.getFile()
assert fprop.exists()
爲beanBuilder.loadBeans我有使用固定的絕對文件URI一個簡單的彈簧文件。我曾嘗試在同一文件夾讀取log4j.properties和工作使用使用ClassPathResource - 並且斷言是罰款
,但如果我嘗試這個尋找SpringBeans.groovy文件
def res = new ClassPathResource ("SpringBeans.groovy")
File fprop = res.getFile()
assert fprop.exists()
也在資源文件夾的根目錄 - 斷言失敗。
爲了讓loadBeans工作,我必須放入一個絕對文件:URI,我想使用classpath窗體 - 但是這找不到它。
爲什麼我可以看到log4j.properties而不是SpringBeans.groovy文件?
任何幫助感激地接受
我已經加入到之後的gradle我的構建文件,以確保我得到的資源目錄。和Eclipse顯示了資源目錄也包含enter code here
sourceSets {
main {
groovy {
srcDir 'src/main/groovy'
}
resources {
srcDir 'src/main/resources'
}
}
}
輝煌 - 謝謝 - 我看過那一節,並沒有真正意識到它做了什麼,所以一直沒有改變。啓用它並在* .groovy上留下複選標記,然後重新生成。和羅,並保持腳本得到放入輸出bin目錄感謝這麼多 –