studenting:
id:1
name:liuyupeng
这个是application.yaml文件中的数据
然后测试
package com;
import com.domain.Student;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class Ch1101SpringbootApplicationTests {
@Autowired
private Student student;
@Test
void contextLoads() {
System.out.println(student);
}
}
结果报错
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'student': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'studenting.name' in value "${studenting.name}"
我的yaml文件都是有叶子图标的