我有一个文件 application.yml 和我的 Spring Boot 应用程序,它不愿意运行。
根据日志,元素 [simulator.geo.b12,simulator.geo.b13,simulator.geo.b21,simulator.geo.c6,simulator.geo.host] 未绑定的原因。然而,这个属性是在 application.yml 中设置的,编译器甚至会返回它的值。
如果有人能帮我解决这个问题,我将不胜感激。
simulator:
geo:
host: http://localhost:8080/
b12: http://localhost:8080/geo/b12
b13: http://localhost:8080/geo/b13
b21: http://localhost:8080/geo/b21
c6: http://localhost:8080/geo/c6
Run Code Online (Sandbox Code Playgroud)
和java类
@Getter
@Configuration
@ConfigurationProperties(prefix = "simulator",ignoreUnknownFields = false)
public class VendorSimulatorProperties {
@Value("${simulator.geo.host:http://localhost:8080/}")
private String initUrl;
@Value("${simulator.geo.b12}")
private String geoB12Url;
@Value("${simulator.geo.b13}")
private String geoB13Url;
@Value("${simulator.geo.b21}")
private String geoB21Url;
@Value("${simulator.geo.c6}")
private String geoC6Url;
}
Run Code Online (Sandbox Code Playgroud)
当我开始运行应用程序时,我收到错误消息:
**************************
APPLICATION FAILED TO START
***************************
Description:
Binding to target [Bindable@1c140c7c type = com.mathartsys.dlc.thirdparty.vendor.config.VendorSimulatorProperties$$EnhancerBySpringCGLIB$$eb0a550b, value = 'provided', annotations = array<Annotation>[@org.springframework.boot.context.properties.ConfigurationProperties(prefix=simulator, value=simulator, ignoreUnknownFields=false, …Run Code Online (Sandbox Code Playgroud)