一、直接使用@Value注解
1、创建一个application.properties文件
#Simple properties
mail.hostname = [email protected]
mail.port = 9000
mail.from = [email protected]
2、在启动类中直接使用
package com.xu.wemall;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.Appli