D small classroom -SpringBoot 2.x micro-channel pay online educational website project combat _2-7 interface configuration files are automatically mapped to the property and the entity class configuration

notes


7, the interface configuration files are automatically mapped to attributes and entity class configuration
    Summary: @value annotations are automatically mapped to profile attributes and entity class

            1, or added @Component Configuration annotation;
                
            2, using the specified configuration file location @PropertySource annotation; (Properties name Authority: large property sub-module module name)
                # ================================= micro-channel correlation == ================
                # public number
                wxpay.appid = wx5beac15ca207cdd40c
                wxpay.appsecret = 554801238f17fdsdsdd6f96b382fe548215e9


            3, must come by injecting IOC Resource objects to use acquired in class profile values.
                @Autowired
                Private WeChatConfig weChatConfig;

                examples:
                    @Configuration
                    @PropertySource (value = "CLASSPATH: the application.properties")
                    public class WeChatConfig {

                        @Value("${wxpay.appid}")
                        private String appId;

 

Start

Create a profile class

join this class represents configuration is a configuration file

to specify from which he read the document which

indicates that the specified read from the configuration file application.properties

Configuration properties within the configuration file


Notes package must choose springframework below




to generate getter and setter methods

Read test profile.

Copy a testController out


to start the service test








 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/11462884.html