"Daily Error" Spring-boot configuration file not read

Source: Internet
Author: User

When I recently made a project with Spring-boot, I encountered a problem that the custom profile could not read, by defining @propertysource on the Appcation.java class (value = {"Classpath:XXX.properties"} , encoding= "Utf-8"), and then reads the properties file configuration in the component using @value, etc., is always a null value, and the last discovery is that the project data layer is the EJB access that is used. A bean is then defined in the Ejb-config.xml configuration file:

<bean id= "Propertyconfigurer"    class= " Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer "        lazy-init=" false ">        <property name= "Locations" >            <list>                <value>classpath*:jnpurl.properties</value >            </list>        </property>    </bean>

Because of this configuration, the Spring-boot code configuration is overwritten, so the previously configured annotation profile is not read.

The workaround is to place the profile in a uniform location: In a bean that is written uniformly in a configuration file, or in a uniform configuration in code annotations.

Spring-boot configuration File Reference:

Http://www.cnblogs.com/hafiz/p/5876243.html

http://blog.csdn.net/je_ge/article/details/54783184

http://tengj.top/2017/02/28/springboot2/

"Daily Error" Spring-boot configuration file not read

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.