在我的程序中,我尝试连接两台服务器。当它们处于不同的项目中时,两种连接都可以完美地工作。然而,当他们在同一个maven项目中时,我在连接过程中遇到了异常。
在我的情况下,当我在我的pom中添加这个依赖
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.9.35</version>
</dependency>
我可以毫无问题地连接到亚马逊服务器。但是,我无法连接到另一台服务器(在我的情况下是Cloud Foundary)。我有这个例外:
Exception in thread "main" org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Can not construct instance of org.springframework.security.oauth2.common.OAuth2AccessToken, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information
at [Source: org.apache.http.conn.EofSensorInputStream@3eb77ea8; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of org.springframework.security.oauth2.common.OAuth2AccessToken, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information
at [Source: org.apache.http.conn.EofSensorInputStream@3eb77ea8; line: 1, column: 1]
at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.readInternal(MappingJackson2HttpMessageConverter.java:126)
at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:153)
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:81)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:454)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:417)
at org.springframework.security.oauth2.client.token.OAuth2AccessTokenSupport.retrieveToken(OAuth2AccessTokenSupport.java:102)
at org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider.obtainAccessToken(ResourceOwnerPasswordAccessTokenProvider.java:47)
at org.cloudfoundry.client.lib.oauth2.OauthClient.getToken(OauthClient.java:66)
at org.cloudfoundry.client.lib.rest.CloudControllerClientImpl.login(CloudControllerClientImpl.java:626)
at org.cloudfoundry.client.lib.CloudFoundryClient.login(CloudFoundryClient.java:149)
at telecom.sudparis.eu.paas.core.server.ressources.manager.application.TestErrors.main(TestErrors.java:27)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of org.springframework.security.oauth2.common.OAuth2AccessToken, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information
at [Source: org.apache.http.conn.EofSensorInputStream@3eb77ea8; line: 1, column: 1]
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:164)
at com.fasterxml.jackson.databind.DeserializationContext.instantiationException(DeserializationContext.java:716)
at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserialize(AbstractDeserializer.java:140)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2993)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2158)
at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.readInternal(MappingJackson2HttpMessageConverter.java:123)
... 10 more
但是,当我删除此依赖项时,我不会遇到连接到Cloud Foudary的问题。但是,我使用了aws类的错误。
我的问题是。如何在没有此异常的情况下添加两个依赖项?