package com.sf; import com.sf.config.FoodConfig; import com.sf.config.VegetablesConfig; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest public class PropertiesTests { @Value("${food.rice}") private String rice; @Value("${food.meat}") private String meat; @Test public void test() { System.out.println(meat + "+" + rice); } @Autowired private FoodConfig foodConfig; @Test public void testFood(){ System.out.println(foodConfig.getMeat()); System.out.println(foodConfig.getRice()); } @Autowired private VegetablesConfig vegetablesConfig; @Test public void testVege(){ System.out.println(vegetablesConfig.getPotato()); System.out.println(vegetablesConfig.getEggplant()); System.out.println(vegetablesConfig.getGreenpeper()); } }