@ConfigurationProperties(prefix="com.imooc.opensource")下出現(xiàn)紅色波浪線
已經(jīng)添加依賴了,但在@ConfigurationProperties(prefix="com.imooc.opensource")會(huì)出錯(cuò),提示說Not registered via @EnableConfigurationProperties or marked as Spring component,但是把@Configuration換成@Component就沒有問題了。這是什么問題?使用的1.5.18版本。
2019-01-16
確保添加了依賴
<dependency>
? ?<groupId> org.springframework.boot </groupId>
? ?<artifactId> spring-boot-configuration-processor </artifactId>
? ?<optional> true </optional>
</dependency>
如果發(fā)現(xiàn)@ConfigurationPropertie不生效,有可能是項(xiàng)目的目錄結(jié)構(gòu)問題,可以通過@EnableConfigurationProperties(ConnectionSettings.class)來明確指定需要用哪個(gè)實(shí)體類來裝載配置信息。
Spring boot 1.5以上去除了location屬性,可采用@Component的方式注冊(cè)為組件,然后使用@PropertySource來指定自定義的資源目錄。
2019-01-08
也遇到了這個(gè)問題,不知道什么原因