- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用假客户端微服务并收到以下错误 -
$ mvn spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] -----------< com.transport.visualizer:transport-visualizer >------------
[INFO] Building transport-visualizer 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:1.5.7.RELEASE:run (default-cli) > test-compile @ transport-visualizer >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ transport-visualizer ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ transport-visualizer ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ transport-visualizer ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/Chaklader/IdeaProjects/TransportationSimulator/TransportVisualizer/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ transport-visualizer ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/Chaklader/IdeaProjects/TransportationSimulator/TransportVisualizer/target/test-classes
[WARNING] error reading /Users/Chaklader/.m2/repository/org/springframework/security/spring-security-crypto/4.2.3.RELEASE/spring-security-crypto-4.2.3.RELEASE.jar; zip file is empty
[WARNING] error reading /Users/Chaklader/.m2/repository/org/springframework/security/spring-security-crypto/4.2.3.RELEASE/spring-security-crypto-4.2.3.RELEASE.jar; zip file is empty
[INFO]
[INFO] <<< spring-boot-maven-plugin:1.5.7.RELEASE:run (default-cli) < test-compile @ transport-visualizer <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.7.RELEASE:run (default-cli) @ transport-visualizer ---
[INFO] Attaching agents: []
21:17:03.282 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
21:17:03.285 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
21:17:03.286 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/Users/Chaklader/IdeaProjects/TransportationSimulator/TransportVisualizer/target/classes/]
2020-01-19 21:17:03.760 INFO 12186 --- [ restartedMain] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@578ae32b: startup date [Sun Jan 19 21:17:03 BDT 2020]; root of context hierarchy
2020-01-19 21:17:04.064 INFO 12186 --- [ restartedMain] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2020-01-19 21:17:04.117 INFO 12186 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$8452941d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.7.RELEASE)
2020-01-19 21:17:04.520 INFO 12186 --- [ restartedMain] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888
2020-01-19 21:17:04.622 WARN 12186 --- [ restartedMain] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/webapp/default": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
2020-01-19 21:17:04.623 INFO 12186 --- [ restartedMain] com.transport.visualizer.Application : The following profiles are active: production
2020-01-19 21:17:04.649 INFO 12186 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7c957d13: startup date [Sun Jan 19 21:17:04 BDT 2020]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@578ae32b
2020-01-19 21:17:05.980 INFO 12186 --- [ restartedMain] o.s.cloud.context.scope.GenericScope : BeanFactory id=40c925ff-d39d-33d7-9455-85a8db8efdb0
2020-01-19 21:17:06.021 INFO 12186 --- [ restartedMain] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2020-01-19 21:17:06.191 INFO 12186 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$68389120] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-01-19 21:17:06.411 INFO 12186 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$8452941d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-01-19 21:17:07.106 INFO 12186 --- [ restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2020-01-19 21:17:07.122 INFO 12186 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-01-19 21:17:07.124 INFO 12186 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.20
2020-01-19 21:17:07.581 WARN 12186 --- [ost-startStop-1] o.a.tomcat.util.scan.StandardJarScanner : Failed to scan [file:/Users/Chaklader/.m2/repository/org/springframework/security/spring-security-crypto/4.2.3.RELEASE/spring-security-crypto-4.2.3.RELEASE.jar] from classloader hierarchy
java.util.zip.ZipException: zip file is empty
at java.util.zip.ZipFile.open(Native Method) ~[na:1.8.0_211]
at java.util.zip.ZipFile.<init>(ZipFile.java:225) ~[na:1.8.0_211]
at java.util.zip.ZipFile.<init>(ZipFile.java:155) ~[na:1.8.0_211]
at java.util.jar.JarFile.<init>(JarFile.java:166) ~[na:1.8.0_211]
at java.util.jar.JarFile.<init>(JarFile.java:130) ~[na:1.8.0_211]
at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:60) ~[tomcat-embed-core-8.5.20.jar:8.5.20]
at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49) ~[tomcat-embed-core-8.5.20.jar:8.5.20]
at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:338) ~[tomcat-embed-core-8.5.20.jar:8.5.20]
at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:288) ~[tomcat-embed-core-8.5.20.jar:8.5.20]
at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262) [tomcat-embed-jasper-8.5.20.jar:8.5.20]
at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104) [tomcat-embed-jasper-8.5.20.jar:8.5.20]
at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:101) [tomcat-embed-jasper-8.5.20.jar:8.5.20]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196) [tomcat-embed-core-8.5.20.jar:8.5.20]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.20.jar:8.5.20]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419) [tomcat-embed-core-8.5.20.jar:8.5.20]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) [tomcat-embed-core-8.5.20.jar:8.5.20]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_211]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_211]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_211]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_211]
2020-01-19 21:17:07.587 INFO 12186 --- [ost-startStop-1] org.apache.jasper.servlet.TldScanner : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2020-01-19 21:17:07.591 INFO 12186 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-01-19 21:17:07.591 INFO 12186 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2942 ms
2020-01-19 21:17:07.928 INFO 12186 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2020-01-19 21:17:07.929 INFO 12186 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2020-01-19 21:17:07.929 INFO 12186 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2020-01-19 21:17:07.930 INFO 12186 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2020-01-19 21:17:07.931 INFO 12186 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2020-01-19 21:17:07.932 INFO 12186 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2020-01-19 21:17:07.933 INFO 12186 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'webServlet' to [/h2-console/*]
2020-01-19 21:17:08.576 INFO 12186 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2020-01-19 21:17:08.599 INFO 12186 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2020-01-19 21:17:08.683 INFO 12186 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2020-01-19 21:17:08.685 INFO 12186 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2020-01-19 21:17:08.687 INFO 12186 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2020-01-19 21:17:08.734 INFO 12186 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2020-01-19 21:17:08.868 INFO 12186 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2020-01-19 21:17:09.349 INFO 12186 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000228: Running hbm2ddl schema update
2020-01-19 21:17:09.425 INFO 12186 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-01-19 21:17:09.904 INFO 12186 --- [ restartedMain] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@66bff282: startup date [Sun Jan 19 21:17:09 BDT 2020]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7c957d13
2020-01-19 21:17:09.936 INFO 12186 --- [ restartedMain] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2020-01-19 21:17:10.275 WARN 12186 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'vehicleController': Unsatisfied dependency expressed through field 'externalService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'positionTrackingExternalService': Unsatisfied dependency expressed through field 'remoteService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.transport.visualizer.services.RemotePositionMicroserviceCalls': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException
2020-01-19 21:17:10.276 INFO 12186 --- [ restartedMain] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@66bff282: startup date [Sun Jan 19 21:17:09 BDT 2020]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7c957d13
2020-01-19 21:17:10.278 INFO 12186 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-01-19 21:17:10.285 INFO 12186 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-01-19 21:17:10.308 INFO 12186 --- [ restartedMain] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2020-01-19 21:17:10.314 ERROR 12186 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'vehicleController': Unsatisfied dependency expressed through field 'externalService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'positionTrackingExternalService': Unsatisfied dependency expressed through field 'remoteService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.transport.visualizer.services.RemotePositionMicroserviceCalls': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at com.transport.visualizer.Application.main(Application.java:20) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_211]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_211]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_211]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_211]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.7.RELEASE.jar:1.5.7.RELEASE]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'positionTrackingExternalService': Unsatisfied dependency expressed through field 'remoteService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.transport.visualizer.services.RemotePositionMicroserviceCalls': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.394 s
[INFO] Finished at: 2020-01-19T21:17:10+06:00
[INFO] ------------------------------------------------------------------------
我认为错误的部分很重要,
2020-01-19 21:17:07.581 WARN 12186 --- [ost-startStop-1] o.a.tomcat.util.scan.StandardJarScanner : Failed to scan [file:/Users/Chaklader/.m2/repository/org/springframework/security/spring-security-crypto/4.2.3.RELEASE/spring-security-crypto-4.2.3.RELEASE.jar] from classloader hierarchy
java.util.zip.ZipException: zip file is empty
at java.util.zip.ZipFile.open(Native Method) ~[na:1.8.0_211]
其次,
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2020-01-19 21:17:10.314 ERROR 12186 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'vehicleController': Unsatisfied dependency expressed through field 'externalService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'positionTrackingExternalService': Unsatisfied dependency expressed through field 'remoteService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.transport.visualizer.services.RemotePositionMicroserviceCalls': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException
我的服务等级,
@Service
public class PositionTrackingExternalService {
@Autowired
private RemotePositionMicroserviceCalls remoteService;
@Autowired
private VehicleRepository repository;
@HystrixCommand(fallbackMethod = "handleExternalServiceDown")
public Position getLatestPositionForVehicleFromRemoteMicroservice(String name) {
Position response = remoteService.getLatestPositionForVehicle(name);
response.setUpToDate(true);
return response;
}
public Position handleExternalServiceDown(String name) {
// Read the last known position for this vehicle
Position position = new Position();
Vehicle vehicle = repository.findByName(name);
position.setLat(vehicle.getLat());
position.setLongitude(vehicle.getLongitude());
position.setTimestamp(vehicle.getLastRecordedPosition());
position.setUpToDate(false);
return position;
}
}
假客户端界面,
@FeignClient(name = "fleetman-position-tracker")
public interface RemotePositionMicroserviceCalls {
@GetMapping(value = "/vehicles/{name}")
public Position getLatestPositionForVehicle(@PathVariable(value = "name") String name);
}
主应用程序,
@SpringBootApplication
@EnableCircuitBreaker
@EnableDiscoveryClient
@EnableFeignClients
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}
}
最后,提供了pom.xml
文件,
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.transport.visualizer</groupId>
<artifactId>transport-visualizer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>transport-visualizer</name>
<description>Vehicle visualizer Application</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-ribbon</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<includes>
<include>application.properties</include>
</includes>
</resource>
</resources>
</build>
</project>
这里有什么问题以及如何解决它?
最佳答案
注入(inject) ObjectProvider<RemotePositionMicroserviceCalls>
后似乎可以工作在下面提供的服务类中,
@Service
public class PositionTrackingExternalService {
@Autowired
private ObjectProvider<RemotePositionMicroserviceCalls> remoteService;
@Autowired
private VehicleRepository repository;
@HystrixCommand(fallbackMethod = "handleExternalServiceDown")
public Position getLatestPositionForVehicleFromRemoteMicroservice(String name) {
Position response = remoteService.getObject().getLatestPositionForVehicle(name);
response.setUpToDate(true);
return response;
}
public Position handleExternalServiceDown(String name) {
// Read the last known position for this vehicle
Position position = new Position();
Vehicle vehicle = repository.findByName(name);
position.setLat(vehicle.getLat());
position.setLongitude(vehicle.getLongitude());
position.setTimestamp(vehicle.getLastRecordedPosition());
position.setUpToDate(false);
return position;
}
}
关于java - 假装REST客户端: FactoryBean threw exception on object creation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59811517/
我使用的是基于 Eclipse 3.x 的 WID 6.1。 尝试右键单击文件夹时,新建-> 类,键入类的名称,然后单击完成,出现错误 "Creation of element failed. org
假设我想创建一个浏览器插件,每当某人单击我网页上的按钮时,该插件就会打开他们的软盘驱动器。 (你还记得那个老笑话吗?-别担心,我真的不想这么做。) 创建可在大多数浏览器和大多数操作系统上运行的浏览器插
我目前正在尝试在 Azure 容器实例上创建一个新容器,以在其上部署 .net core 应用程序镜像。 (我是这项技术的新手)。 我在 Azure 上创建了一个容器注册表,并在其上推送了一个镜像(.
我不确定我问的是否正确,但我知道你们都很聪明,能够弄清楚:)。我在压缩一些 python 类中的一些重复代码时遇到了麻烦。这是我的意思的一个例子...... class Parent: PAT
我想要扩展这些 C 预处理器行: #define _POUND_ #define _POUND_ _FALSE 0 _FALSE 展开,最后一行(即_FALSE)展开为0。我知道递归CPP不可能直接实
我需要创建 generic list可以充当List或 List因为我有以下情况。 if(e instanceof A) return A; else return B 但我想填充一个 List Re
我正在尝试构建一个共享对象,以便稍后在其他项目中使用共享对象中的函数 DoSomethingUseful()。它使用外部库以及我在多个项目中使用的一堆 header 。 使用 CMake,我创建了一个
void foo() { //some code MyClass m(); //some more code } C++ 标准是否确保 MyClass 类的构造函数将在 /
我正在尝试在 2D 游戏中创建斜坡。这个斜坡应该有一个 X 度。当现在一个球“滚过”这个斜坡时。这个坡度的效果应该改变,然后球的行为因此向后滚动,向前滚动或在其他地方初始化倾斜度。我认为我可以使用具有
我有一个开发分支,我想看看“分支创建”和现在的区别。实际上,我更感兴趣的是创建分支之后的提交,这更像是“创建分支”+1。 我知道我可以在 Git 命令中使用像 HEAD 和 HEAD~1 这样的简写。
在JavaScript: Understanding the Weird Parts讲师解释说,变量的内存是在所谓的创建阶段设置的(并且 undefined 已分配);然后执行阶段发生。但是,当我们不
我需要NodeJS代码来创建POST请求,以便从URL创建一个FB页面。必须代码有错误,我找不到它。错误消息为请求失败,状态代码为400。我没有包含accesToken字符串,但它存在于我的实际代码中
我开发了一个具有以下特点的 Fortran 代码: 全局变量 13 个带有多个子程序的模块 独立子程序 将英特尔 MKL 库用于 LAPACK 库(线性代数) 读写文本文件 代码变得相当大。即使在这个
我想创建一个数组 ArrayList .我尝试了以下方法: static ArrayList[] displayBlocks = new ArrayList[3]; 但是,我收到编译时错误: gene
云信息supports通过“堆栈创建选项”设置超时。但是这个部分在 serverless.yml 中?有什么解决方法吗? 最佳答案 查看actual code ,TimeoutInMinutes 参数
我们希望只有部分人能够在 Azure DevOps 云(?)存储库中创建“release/*”分支。 不幸的是,我在用户界面中找不到这个选项。我这里也找不到 https://learn.microso
我使用 Azure AD Graph API 差异查询来检测 Azure AD 中的更改。 对于 User 或 Group 类型的每个结果节点,如何区分该对象是新的还是仅更新的? 我使用ocp-aad
我正在发布简单的数据,例如 { "title" : "test Title" } 到(顺其自然)/posts uri,例如类似 RestAssured.baseURI = "http://localh
我正在尝试为撇号创建一个产品引擎。我在扩展“页面设置”表单时遇到问题,目前我想添加一个简单的文本区域来向页面添加概要 - 最终我想添加“产品”设置,但我需要先完成基础知识。 我创建了一个表单和一个设置
我使用 Azure AD Graph API 差异查询来检测 Azure AD 中的更改。 对于 User 或 Group 类型的每个结果节点,如何区分该对象是新的还是仅更新的? 我使用ocp-aad
我是一名优秀的程序员,十分优秀!