Java HttpSecurity不适用于Spring Boot 1.1.7

Java HttpSecurity不适用于Spring Boot 1.1.7,java,spring,spring-security,oauth-2.0,spring-security-oauth2,Java,Spring,Spring Security,Oauth 2.0,Spring Security Oauth2,我正试图根据示例在我的移动应用程序后端实现OAuth2安全性 该示例使用springBootVersion='1.0.2.RELEASE'。在我的项目中,我使用的是1.1.7.RELEASE。在收到几个令人费解的400错误请求后,我开始配对依赖项 因此,当我将示例spring引导版本设置为我的版本时,它停止编译。特别是找不到**.*之间的方法 // This method configures the OAuth scopes required by clients to access

我正试图根据示例在我的移动应用程序后端实现OAuth2安全性

该示例使用springBootVersion='1.0.2.RELEASE'。在我的项目中,我使用的是1.1.7.RELEASE。在收到几个令人费解的400错误请求后,我开始配对依赖项

因此,当我将示例spring引导版本设置为我的版本时,它停止编译。特别是找不到**.*之间的方法

// This method configures the OAuth scopes required by clients to access
        // all of the paths in the video service.
        @Override
        public void configure(HttpSecurity http) throws Exception {
            http.**csrf**().disable();
            http
                    .**authorizeRequests**()
                    .antMatchers("/oauth/token").anonymous();
            http
                    .**authorizeRequests**()
                    .antMatchers(HttpMethod.GET, "/**")
                    .access("#oauth2.hasScope('read')");
            http
                    .**authorizeRequests**()
                    .antMatchers("/**")
                    .access("#oauth2.hasScope('write')");
        }
        }
我认为应用程序中的安全性的相关渐变依赖性是:

compile("org.springframework.boot:spring-boot-starter-security:${springBootVersion}")
compile("org.springframework.security.oauth:spring-security-oauth2:2.0.0.RC2")
compile("org.springframework.security.oauth:spring-security-oauth2-javaconfig:1.0.0.M1")
这些是示例中的原始示例。然而,有趣的是,在我的应用程序中,我从未得到编译错误,但它也不起作用。使用示例应用程序运行的测试用例运行良好

我真的很困惑。我是否应该更改这些依赖项中的任何一个?提前感谢您的支持

编辑

简单问候控制器:

public interface GreetingSvcApi {
    public static final String GREETING_PATH = "/greeting";
    @GET(GREETING_PATH)
    public Greeting greeting(@Query("name") String name);
}

@Controller
public class GreetingController {
    @RequestMapping(value = GreetingSvcApi.GREETING_PATH, method = RequestMethod.GET)
    public
    @ResponseBody
    Greeting greeting(@RequestParam(value = "name", required = false, defaultValue = "Hello Developer") String name) {
        return new Greeting(name);
    }
}

public class GreetingControllerTest extends TestCase {

    private final String USERNAME = "admin";
    private final String PASSWORD = "pass";
    private final String CLIENT_ID = "mobile";
    private final String READ_ONLY_CLIENT_ID = "mobileReader";

    private GreetingSvcApi greetingService = new SecuredRestBuilder()
            .setLoginEndpoint(RestDataFixture.SERVER_HTTPS + BaseServiceApi.TOKEN_PATH)
            .setUsername(USERNAME)
            .setPassword(PASSWORD)
            .setClientId(CLIENT_ID)
            .setClient(new ApacheClient(UnsafeHttpsClient.createUnsafeClient()))
            .setEndpoint(RestDataFixture.SERVER_HTTPS).setLogLevel(RestAdapter.LogLevel.FULL).build()
            .create(GreetingSvcApi.class);

    public void testGreetingInHttp() throws Exception {

        Greeting greeting = greetingService.greeting("Greeting");
        assertEquals(greeting.getPerson(), "Greeting");
    }
}
预期产出:

o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: best-match
o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context
o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://localhost:8443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {s}->https://localhost:8443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
o.a.h.impl.execchain.MainClientExec - Opening connection {s}->https://localhost:8443
o.a.h.i.c.HttpClientConnectionOperator - Connecting to localhost/127.0.0.1:8443
o.a.h.i.c.HttpClientConnectionOperator - Connection established 127.0.0.1:57518<->127.0.0.1:8443
o.a.h.impl.execchain.MainClientExec - Executing request POST /oauth/token HTTP/1.1
o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
org.apache.http.headers - http-outgoing-0 >> POST /oauth/token HTTP/1.1
org.apache.http.headers - http-outgoing-0 >> Authorization: Basic bW9iaWxlOg==
org.apache.http.headers - http-outgoing-0 >> Content-Length: 80
org.apache.http.headers - http-outgoing-0 >> Content-Type: application/x-www-form-urlencoded; charset=UTF-8
org.apache.http.headers - http-outgoing-0 >> Host: localhost:8443
org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive
org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.3.4 (java 1.5)
org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate
org.apache.http.wire - http-outgoing-0 >> "POST /oauth/token HTTP/1.1[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Authorization: Basic bW9iaWxlOg==[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Content-Length: 80[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Content-Type: application/x-www-form-urlencoded; charset=UTF-8[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Host: localhost:8443[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.3.4 (java 1.5)[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "username=admin&password=pass&client_id=mobile&client_secret=&grant_type=password"
org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Server: Apache-Coyote/1.1[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "X-Content-Type-Options: nosniff[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "X-XSS-Protection: 1; mode=block[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Cache-Control: no-cache, no-store, max-age=0, must-revalidate[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Pragma: no-cache[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Expires: 0[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Strict-Transport-Security: max-age=31536000 ; includeSubDomains[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "X-Frame-Options: DENY[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "X-Application-Context: application[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Cache-Control: no-store[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Pragma: no-cache[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Content-Type: application/hal+json[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Transfer-Encoding: chunked[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Date: Fri, 31 Oct 2014 19:03:42 GMT[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "75[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "{"access_token":"1a59e04c-afb0-40cd-9e17-4e573beea347","token_type":"bearer","expires_in":43199,"scope":"read write"}[\r][\n]"
org.apache.http.headers - http-outgoing-0 << HTTP/1.1 200 OK
org.apache.http.headers - http-outgoing-0 << Server: Apache-Coyote/1.1
org.apache.http.headers - http-outgoing-0 << X-Content-Type-Options: nosniff
org.apache.http.headers - http-outgoing-0 << X-XSS-Protection: 1; mode=block
org.apache.http.headers - http-outgoing-0 << Cache-Control: no-cache, no-store, max-age=0, must-revalidate
org.apache.http.headers - http-outgoing-0 << Pragma: no-cache
org.apache.http.headers - http-outgoing-0 << Expires: 0
org.apache.http.headers - http-outgoing-0 << Strict-Transport-Security: max-age=31536000 ; includeSubDomains
org.apache.http.headers - http-outgoing-0 << X-Frame-Options: DENY
org.apache.http.headers - http-outgoing-0 << X-Application-Context: application
org.apache.http.headers - http-outgoing-0 << Cache-Control: no-store
org.apache.http.headers - http-outgoing-0 << Pragma: no-cache
org.apache.http.headers - http-outgoing-0 << Content-Type: application/hal+json
org.apache.http.headers - http-outgoing-0 << Transfer-Encoding: chunked
org.apache.http.headers - http-outgoing-0 << Date: Fri, 31 Oct 2014 19:03:42 GMT
o.a.h.impl.execchain.MainClientExec - Connection can be kept alive indefinitely
org.apache.http.wire - http-outgoing-0 << "0[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
o.a.h.i.c.PoolingHttpClientConnectionManager - Connection [id: 0][route: {s}->https://localhost:8443] can be kept alive indefinitely
o.a.h.i.c.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {s}->https://localhost:8443][total kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20]
---> HTTP GET https://localhost:8443/greeting?name=Greeting
Authorization: Bearer 1a59e04c-afb0-40cd-9e17-4e573beea347
---> END HTTP (no body)
o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: best-match
o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context
o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://localhost:8443][total kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20]
o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {s}->https://localhost:8443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
o.a.h.impl.execchain.MainClientExec - Stale connection check
org.apache.http.wire - http-outgoing-0 << "[read] I/O error: Read timed out"
o.a.h.impl.execchain.MainClientExec - Executing request GET /greeting?name=Greeting HTTP/1.1
o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
org.apache.http.headers - http-outgoing-0 >> GET /greeting?name=Greeting HTTP/1.1
org.apache.http.headers - http-outgoing-0 >> Authorization: Bearer 1a59e04c-afb0-40cd-9e17-4e573beea347
org.apache.http.headers - http-outgoing-0 >> Host: localhost:8443
org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive
org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.3.4 (java 1.5)
org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate
org.apache.http.wire - http-outgoing-0 >> "GET /greeting?name=Greeting HTTP/1.1[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Authorization: Bearer 1a59e04c-afb0-40cd-9e17-4e573beea347[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Host: localhost:8443[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.3.4 (java 1.5)[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Server: Apache-Coyote/1.1[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "X-Content-Type-Options: nosniff[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "X-XSS-Protection: 1; mode=block[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Cache-Control: no-cache, no-store, max-age=0, must-revalidate[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Pragma: no-cache[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Expires: 0[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Strict-Transport-Security: max-age=31536000 ; includeSubDomains[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "X-Frame-Options: DENY[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Set-Cookie: JSESSIONID=8FC93D46387663ED9D1EA7F97C7F9B45; Path=/; Secure; HttpOnly[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "X-Application-Context: application[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Content-Type: application/hal+json[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Transfer-Encoding: chunked[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Date: Fri, 31 Oct 2014 19:03:42 GMT[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "2a[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "{"person":"Greeting","date":1414782222693}[\r][\n]"
org.apache.http.headers - http-outgoing-0 << HTTP/1.1 200 OK
org.apache.http.headers - http-outgoing-0 << Server: Apache-Coyote/1.1
org.apache.http.headers - http-outgoing-0 << X-Content-Type-Options: nosniff
org.apache.http.headers - http-outgoing-0 << X-XSS-Protection: 1; mode=block
org.apache.http.headers - http-outgoing-0 << Cache-Control: no-cache, no-store, max-age=0, must-revalidate
org.apache.http.headers - http-outgoing-0 << Pragma: no-cache
org.apache.http.headers - http-outgoing-0 << Expires: 0
org.apache.http.headers - http-outgoing-0 << Strict-Transport-Security: max-age=31536000 ; includeSubDomains
org.apache.http.headers - http-outgoing-0 << X-Frame-Options: DENY
org.apache.http.headers - http-outgoing-0 << Set-Cookie: JSESSIONID=8FC93D46387663ED9D1EA7F97C7F9B45; Path=/; Secure; HttpOnly
org.apache.http.headers - http-outgoing-0 << X-Application-Context: application
org.apache.http.headers - http-outgoing-0 << Content-Type: application/hal+json
org.apache.http.headers - http-outgoing-0 << Transfer-Encoding: chunked
org.apache.http.headers - http-outgoing-0 << Date: Fri, 31 Oct 2014 19:03:42 GMT
o.a.h.impl.execchain.MainClientExec - Connection can be kept alive indefinitely
o.a.h.c.p.ResponseProcessCookies - Cookie accepted [JSESSIONID="8FC93D46387663ED9D1EA7F97C7F9B45", version:0, domain:localhost, path:/, expiry:null]
org.apache.http.wire - http-outgoing-0 << "0[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
o.a.h.i.c.PoolingHttpClientConnectionManager - Connection [id: 0][route: {s}->https://localhost:8443] can be kept alive indefinitely
o.a.h.i.c.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {s}->https://localhost:8443][total kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20]
<--- HTTP 200 https://localhost:8443/greeting?name=Greeting (324ms)
Server: Apache-Coyote/1.1
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Frame-Options: DENY
Set-Cookie: JSESSIONID=8FC93D46387663ED9D1EA7F97C7F9B45; Path=/; Secure; HttpOnly
X-Application-Context: application
Content-Type: application/hal+json
Transfer-Encoding: chunked
Date: Fri, 31 Oct 2014 19:03:42 GMT

{"person":"Greeting","date":1414782222693}
<--- END HTTP (42-byte body)

Process finished with exit code 0
实际产量:

o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: best-match
o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context
o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://localhost:8443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {s}->https://localhost:8443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
o.a.h.impl.execchain.MainClientExec - Opening connection {s}->https://localhost:8443
o.a.h.i.c.HttpClientConnectionOperator - Connecting to localhost/127.0.0.1:8443
o.a.h.i.c.HttpClientConnectionOperator - Connection established 127.0.0.1:55456<->127.0.0.1:8443
o.a.h.impl.execchain.MainClientExec - Executing request POST /oauth/token HTTP/1.1
o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
org.apache.http.headers - http-outgoing-0 >> POST /oauth/token HTTP/1.1
org.apache.http.headers - http-outgoing-0 >> Authorization: Basic bW9iaWxlOg==
org.apache.http.headers - http-outgoing-0 >> Content-Length: 80
org.apache.http.headers - http-outgoing-0 >> Content-Type: application/x-www-form-urlencoded; charset=UTF-8
org.apache.http.headers - http-outgoing-0 >> Host: localhost:8443
org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive
org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.3.4 (java 1.5)
org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate
org.apache.http.wire - http-outgoing-0 >> "POST /oauth/token HTTP/1.1[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Authorization: Basic bW9iaWxlOg==[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Content-Length: 80[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Content-Type: application/x-www-form-urlencoded; charset=UTF-8[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Host: localhost:8443[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.3.4 (java 1.5)[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"
org.apache.http.wire - http-outgoing-0 >> "username=admin&password=pass&client_id=mobile&client_secret=&grant_type=password"
org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 400 Bad Request[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Server: Apache-Coyote/1.1[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "X-Content-Type-Options: nosniff[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "X-XSS-Protection: 1; mode=block[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Cache-Control: no-cache, no-store, max-age=0, must-revalidate[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Pragma: no-cache[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Expires: 0[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Strict-Transport-Security: max-age=31536000 ; includeSubDomains[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "X-Frame-Options: DENY[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "X-Application-Context: application:8443[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Cache-Control: no-store[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Pragma: no-cache[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Content-Type: application/json;charset=UTF-8[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Transfer-Encoding: chunked[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Date: Fri, 31 Oct 2014 18:06:51 GMT[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "Connection: close[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "3f[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "{"error":"invalid_grant","error_description":"Bad credentials"}[\r][\n]"
org.apache.http.headers - http-outgoing-0 << HTTP/1.1 400 Bad Request
org.apache.http.headers - http-outgoing-0 << Server: Apache-Coyote/1.1
org.apache.http.headers - http-outgoing-0 << X-Content-Type-Options: nosniff
org.apache.http.headers - http-outgoing-0 << X-XSS-Protection: 1; mode=block
org.apache.http.headers - http-outgoing-0 << Cache-Control: no-cache, no-store, max-age=0, must-revalidate
org.apache.http.headers - http-outgoing-0 << Pragma: no-cache
org.apache.http.headers - http-outgoing-0 << Expires: 0
org.apache.http.headers - http-outgoing-0 << Strict-Transport-Security: max-age=31536000 ; includeSubDomains
org.apache.http.headers - http-outgoing-0 << X-Frame-Options: DENY
org.apache.http.headers - http-outgoing-0 << X-Application-Context: application:8443
org.apache.http.headers - http-outgoing-0 << Cache-Control: no-store
org.apache.http.headers - http-outgoing-0 << Pragma: no-cache
org.apache.http.headers - http-outgoing-0 << Content-Type: application/json;charset=UTF-8
org.apache.http.headers - http-outgoing-0 << Transfer-Encoding: chunked
org.apache.http.headers - http-outgoing-0 << Date: Fri, 31 Oct 2014 18:06:51 GMT
org.apache.http.headers - http-outgoing-0 << Connection: close
org.apache.http.wire - http-outgoing-0 << "0[\r][\n]"
org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: Shutdown connection
o.a.h.impl.execchain.MainClientExec - Connection discarded
o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: Close connection
o.a.h.i.c.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {s}->https://localhost:8443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
---- ERROR 
org.portotech.pague360mpayments.security.SecuredRestException: org.portotech.pague360mpayments.security.SecuredRestException: Login failure: 400 - Bad Request
    at org.portotech.pague360mpayments.security.SecuredRestBuilder$OAuthHandler.intercept(SecuredRestBuilder.java:150)
    at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:300)
    at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
    at com.sun.proxy.$Proxy2.greeting(Unknown Source)
    at org.portotech.pague360mpayments.rest.controller.GreetingControllerTest.testGreetingInHttp(GreetingControllerTest.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at junit.framework.TestCase.runTest(TestCase.java:176)
    at junit.framework.TestCase.runBare(TestCase.java:141)
    at junit.framework.TestResult$1.protect(TestResult.java:122)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.framework.TestResult.run(TestResult.java:125)
    at junit.framework.TestCase.run(TestCase.java:129)
    at junit.framework.TestSuite.runTest(TestSuite.java:255)
    at junit.framework.TestSuite.run(TestSuite.java:250)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: org.portotech.pague360mpayments.security.SecuredRestException: Login failure: 400 - Bad Request
    at org.portotech.pague360mpayments.security.SecuredRestBuilder$OAuthHandler.intercept(SecuredRestBuilder.java:138)
    ... 26 more

---- END ERROR

retrofit.RetrofitError: org.portotech.pague360mpayments.security.SecuredRestException: Login failure: 400 - Bad Request
    at retrofit.RetrofitError.unexpectedError(RetrofitError.java:44)
    at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:395)
    at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
    at com.sun.proxy.$Proxy2.greeting(Unknown Source)
    at org.portotech.pague360mpayments.rest.controller.GreetingControllerTest.testGreetingInHttp(GreetingControllerTest.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: org.portotech.pague360mpayments.security.SecuredRestException: org.portotech.pague360mpayments.security.SecuredRestException: Login failure: 400 - Bad Request
    at org.portotech.pague360mpayments.security.SecuredRestBuilder$OAuthHandler.intercept(SecuredRestBuilder.java:150)
    at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:300)
    ... 25 more
Caused by: org.portotech.pague360mpayments.security.SecuredRestException: Login failure: 400 - Bad Request
    at org.portotech.pague360mpayments.security.SecuredRestBuilder$OAuthHandler.intercept(SecuredRestBuilder.java:138)
    ... 26 more


Process finished with exit code 255

撇开前面提到的示例应用程序的奇怪实现不谈,Spring Boot中存在或曾经存在一个问题,这使事情变得困难。这里介绍了一种变通方法,在中也有使用。

我想很多人都在学习这门课程,因为我经常看到相同的代码。这是一个有点奇怪的例子,有人应该告诉作者联系我聊天,也许他可以向我解释一下。但是我不知道为什么这些方法会出现编译错误,因为它们不是新的。你只需要刷新IDE还是别的什么?你并没有说什么在我的应用程序中不起作用,所以更多的细节可能是个好主意。嗨,戴夫。是的,我想这不是一个很好的代码,可能只是出于教育目的。刷新IDE不起作用,我甚至已经清理了gradle缓存,其他一切都可以做到。我能做的是为客户端生成一个令牌。我会在我的问题中粘贴两个输出,正确的和我的。我不确定我在看什么。我以为你说有编译错误?