1. 程式人生 > >spring 使用@value無法注入的問題

spring 使用@value無法注入的問題

@value是讀取配置檔案的值
1,首先spring需要掃描指定的配置檔案

     載入配置檔案
    <context:property-placeholder location="classpath:resource/*.properties" />
    此處使用*.properties 掃描 resource資料夾下面所有後綴為resource的檔案

2,掃描指定的包

<context:component-scan base-package="com.user.service"></context:component-scan>`

困擾我今天的問題 是base-package 掃描錯包了 導致一直讀取不到配置檔案的資訊 …