Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法获取用户详细信息:类org.springframework.web.client.RestClientException,无法提取响应:无合适的_Java_Spring_Spring Boot_Spring Oauth2 - Fatal编程技术网

Java 无法获取用户详细信息:类org.springframework.web.client.RestClientException,无法提取响应:无合适的

Java 无法获取用户详细信息:类org.springframework.web.client.RestClientException,无法提取响应:无合适的,java,spring,spring-boot,spring-oauth2,Java,Spring,Spring Boot,Spring Oauth2,我在生成简单应用程序时收到此错误消息 正在从以下位置获取用户信息: 无法获取用户详细信息:类org.springframework.web.client.RestClientException,无法提取响应:未找到响应类型[interface java.util.Map]和内容类型[text/html;charset=UTF-8]的合适HttpMessageConverter 但是,我确信内容类型是json 这是github存储库 这是服务器 @SpringBootApplication pub

我在生成简单应用程序时收到此错误消息

正在从以下位置获取用户信息: 无法获取用户详细信息:类org.springframework.web.client.RestClientException,无法提取响应:未找到响应类型[interface java.util.Map]和内容类型[text/html;charset=UTF-8]的合适HttpMessageConverter

但是,我确信内容类型是json

这是github存储库

这是服务器

@SpringBootApplication
public class AuthServerApplication {

public static void main(String[] args) {
    SpringApplication.run(AuthServerApplication.class, args);
}
}

@Order(1)
@Configuration
@EnableWebSecurity
class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws     Exception {
      auth.inMemoryAuthentication().withUser("ashraf").password("ashraf").roles("user");
}

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/user").authenticated().and().formLogin();
}

@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}
}

@Configuration
class OAuth2ServerConfig {
private static final String RESOURCE_IDS = "revo";

@Configuration
@EnableResourceServer
protected static class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
    @Override
    public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
        resources.resourceId(RESOURCE_IDS);
    }

    @Override
    public void configure(HttpSecurity http) throws Exception {

        http.authorizeRequests().antMatchers("/user").authenticated();
    }
}

@Configuration
@EnableAuthorizationServer
protected static class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {
    @Autowired
    TokenStore tokenStore;

    @Autowired
    private AuthenticationManager authenticationManager;

    @Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        clients.inMemory().withClient("revo")
                .resourceIds(RESOURCE_IDS)
                .authorizedGrantTypes("authorization_code", "implicit")
                .authorities("ROLE_CLIENT")
                .scopes("read", "write")
                .secret("revo");
    }

    @Bean
    public TokenStore tokenStore() {
        return new InMemoryTokenStore();
    }

    @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
        endpoints.tokenStore(tokenStore)
                .authenticationManager(authenticationManager);
    }
}

}
这是客户

@SpringBootApplication
public class ClientApplication {

public static void main(String[] args) {
    SpringApplication.run(ClientApplication.class, args);
}
}

@Configuration
@EnableOAuth2Sso
class SecurityConfigurer extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().mvcMatchers("/home").authenticated();
}
}

 @Configuration
 class MvcConfigurer extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/").setViewName("index");
    registry.addViewController("/home").setViewName("home");
}
}

你可以考虑Spring BooE版本和Spring云版本,选择最新版本,比如Spring BooT-1.4.4版本和Spring Culdi-CAMDENS.SR5;因为我遇到了同样的麻烦,并通过这种方式解决了

< P>你可以考虑Spring BooE版本和Spring云版本,选择一个最新版本,比如Spring BooT-1.4.4版本和Spring Culdi-CAMDENS.SR5;因为我遇到了同样的问题,并通过这种方式解决了问题,如果您可以控制服务器响应,请修改它,将内容类型设置为application/json

请试一试

@RequestMapping(value = "/user", method = RequestMethod.GET, 
produces = "application/json; charset=utf-8")

如果可以控制服务器响应,请修改它以将内容类型设置为application/json

请试一试

@RequestMapping(value = "/user", method = RequestMethod.GET, 
produces = "application/json; charset=utf-8")

您请求“text/html”,但希望收到“application/json”。那不行。我无法控制发送此请求。spring EnableOAuth2Sso发送请求获取用户信息您可以发布完整的异常stacktrace吗?您请求“text/html”,但希望收到“application/json”。那不行。我无法控制发送此请求。spring EnableOAuth2Sso发送请求获取用户信息您可以发布完整的异常stacktrace吗?您的答案是否与所问问题相关?我在使用spring-boot-1.5.2.RELEASE和spring cloud Dalston时遇到了相同的问题,所以我只是给出我的建议你的答案是否与问题相关?我在使用spring-boot-1.5.2.RELEASE和spring cloud Dalston时遇到了同样的问题,所以我只是给出我的建议