package com.suisung.mall.admin; import com.suisung.mall.admin.service.AccountBaseConfigService; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest class MallAccountApplicationTests { @Autowired private AccountBaseConfigService accountBaseConfigService; @Test void contextLoads() { } /** * {@link org.springframework.beans.factory.annotation.Value}标签中调用方法赋值 */ @Value("#{accountBaseConfigService.getConfig('aliyun_app_id')}") private String variable; @Test public void function() { System.out.println(variable); } }