1.现象
Connected to the target VM, address: '127.0.0.1:58510', transport: 'socket
Disconnected from the target VM, address: '127.0.0.1:58510', transport: 'socket'
Process finished with exit code 1
2.原因
一般都是配置项的问题,包括yml配置文件或者其他一些日志呀什么的配置文件.也就是程序run()启动后会先去加载相关启动配置项.如果你新加了某些配置后启动失败了,尝试下还原后再次启动来验证.我这里就指定环境的时候写错了,导致找不到Apollo配置项.
3.解决
在启动类run()方法加上try-catch,捕获最顶级的Throwable就会看到报错信息.
public static void main(String[] args) {
try {
SpringApplication.run(Application.class, args);
} catch (Throwable e) {
e.printStackTrace();
}
}
到这里就可以看到相关错误信息(只截取了一小段),解决方法不就呼出欲知了吗
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'XxxController': Unsatisfied dependency expressed through field 'XxxService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'XxxService': Unsatisfied dependency expressed through field 'XxxService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XxxService': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'gateway.url' in value "${gateway.url}"