我正在尝试让docker在我的AWS上运行并使用docker-compose。我运行maven构建,一切都成功构建但是当我做docker-compose时,我得到这个假装异常,说我的businessDelegate没有自动装配,因为我的假装服务正在获取参数0
这是我的委托类
@Component
public class BusinessDelegateImpl implements BusinessDelegate{
private ShippingService shippingService;
@Autowired
public void setShippingService(ShippingService shippingService) {this.shippingService = shippingService;}
/**More Methods below**/
}
简单吧?就我所见,一切都正确连线。这是我的假装客户类
@FeignClient("shipping")
public interface ShippingService {
@RequestMapping(value = "/insert",
method = RequestMethod.POST,
produces = APPLICATION_JSON_VALUE,
consumes = APPLICATION_JSON_VALUE)
ResponseEntity<Shipping> insert(@RequestBody Shipping shipping);
@RequestMapping(value = "/save",
method = RequestMethod.PUT,
produces = APPLICATION_JSON_VALUE,
consumes = APPLICATION_JSON_VALUE)
ResponseEntity<Shipping> save(@RequestBody Shipping shipping);
@RequestMapping(value = "/cart/{cartId}",
method = RequestMethod.GET,
produces= MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Shipping> findByCartId(@PathVariable("cartId") String cartId);
@RequestMapping(value = "/invoice/{invoiceId}",
method = RequestMethod.GET,
produces= MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Shipping> findByInvoiceId(@PathVariable("invoiceId") String invoiceId);
@RequestMapping(value = "/delete/{id}",
method = RequestMethod.DELETE)
ResponseEntity delete(@PathVariable("id") String id);
}
我在本地遇到此错误,但我通过将变量放在PathVariable @PathVariable("id")
旁边来修复它。现在,只要我在AWS中启动一个docker,我就会得到这个。 mvn构建也运行。如果需要,这是完整的堆栈跟踪。购物是SprintBootApp的名称
shopping | org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'businessDelegateImpl': Unsatisfied dependency expressed through method 'setShippingService' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.revature.service.implementation.ShippingService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: PathVariable annotation was empty on param 0.
shopping | at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:671) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:370) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1219) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.b eans.factory.support. AbstractAutowireCapab leBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:754) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) ~[spring-context-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
shopping | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
shopping | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
shopping | at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
shopping | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
shopping | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
shopping | at com.revature.ApigatewayApplication.main(ApigatewayApplication.java:15) [classes!/:0.0.1-SNAPSHOT]
shopping | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_111]
shopping | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_111]
shopping | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_111]
shopping | at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_111]
shopping | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [apigateway.jar:0.0.1-SNAPSHOT]
shopping | at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [apigateway.jar:0.0.1-SNAPSHOT]
shopping | at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [apigateway.jar:0.0.1-SNAPSHOT]
shopping | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [apigateway.jar:0.0.1-SNAPSHOT]
shopping | Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.revature.service.implementation.ShippingService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: PathVariable annotation was empty on param 0.
shopping | at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1606) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1289) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1258) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1094) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1059) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:663) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | ... 27 common frames omitted
shopping | Caused by: java.lang.IllegalStateException: PathVariable annotation was empty on param 0.
shopping | at feign.Util.checkState(Util.java:128) ~[feign-core-9.3.1.jar!/:na]
shopping | at org.springframework.cloud.netflix.feign.annotation.PathVariableParameterProcessor.processArgument(PathVariableParameterProcessor.java:49) ~[spring-cloud-netflix-core-1.2.5.RELEASE.jar!/:1.2.5.RELEASE]
shopping | at org.springframework.cloud.netflix.feign.support.SpringMvcContract.processAnnotationsOnParameter(SpringMvcContract.java:237) ~[spring-cloud-netflix-core-1.2.5.RELEASE.jar!/:1.2.5.RELEASE]
shopping | at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:107) ~[feign-core-9.3.1.jar!/:na]
shopping | at org.springframework.cloud.netflix.feign.support.SpringMvcContract.parseAndValidateMetadata(SpringMvcContract.java:133) ~[spring-cloud-netflix-core-1.2.5.RELEASE.jar!/:1.2.5.RELEASE]
shopping | at feign.Contract$BaseContract.parseAndValidatateMetadata(Contract.java:64) ~[feign-core-9.3.1.jar!/:na]
shopping | at feign.hystrix.HystrixDelegatingContract.parseAndValidatateMetadata(HystrixDelegatingContract.java:34) ~[feign-hystrix-9.3.1.jar!/:na]
shopping | at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:146) ~[feign-core-9.3.1.jar!/:na]
shopping | at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:53) ~[feign-core-9.3.1.jar!/:na]
shopping | at feign.Feign$Builder.target(Feign.java:209) ~[feign-core-9.3.1.jar!/:na]
shopping | at org.springframework.cloud.netflix.feign.HystrixTargeter.target(HystrixTargeter.java:48) ~[spring-cloud-netflix-core-1.2.5.RELEASE.jar!/:1.2.5.RELEASE]
shopping | at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.loadBalance(FeignClientFactoryBean.java:146) ~[spring-cloud-netflix-core-1.2.5.RELEASE.jar!/:1.2.5.RELEASE]
shopping | at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:167) ~[spring-cloud-netflix-core-1.2.5.RELEASE.jar!/:1.2.5.RELEASE]
shopping | at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
shopping | ... 37 common frames omitted
shopping |
shopping exited with code 1
如果您需要更多信息,请告诉我们。我被困在这几个小时
答案 0 :(得分:1)
我发现了这个问题。我需要首先删除图像并重新创建它。 对于任何不知道如何删除图像的人,首先需要删除容器,例如
docker rm <Container Id>
或立即删除它们
docker rm $(docker ps -a -q)
然后你可以删除图像
docker rmi <Image Id>
或立即删除所有
docker rmi $(docker images -a -q)
要获取ID,请为容器ID输入docker ps -a
,为图像ID输入docker images
或者,如果安装了docker-compose,则可以使用命令重建图像
docker-compose up -d --build
docker-compose pull
docker-compose up