-1

我試圖在我的移動應用後端根據this示例實現OAuth2安全性。HttpSecurity不能與Spring Boot一起工作1.1.7

該示例使用。在我的項目中,我使用的是1.1.7.RELEASE。在發生了幾個無法解釋的400 - 錯誤請求之後,我開始配對依賴關係。

所以,當我設置示例春季啓動版本等於我的,它停止編譯。特別是**。**之間的方法無法找到。

// 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')"); 
     } 
     } 

我相信有關gradle這個依賴於安全應用程序是:

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") 

這些都是在例子中發現原有的。然而,有趣的是,在我的應用程序中,我從來不會編譯錯誤,但它也行不通。我的示例應用程序運行的測試用例運行良好。

我真的很困惑。我應該改變這些依賴關係嗎?預先感謝您的支持。

EDIT

簡單的問候控制器:

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 
+0

我想很多人都在這樣做,因爲我看到很多相同的代碼。這是一個奇怪的例子(有人應該告訴作者聯繫我聊天,也許他可以向我解釋)。但我不知道爲什麼你會有這些方法的編譯錯誤,因爲它們不是新的。你只需要刷新IDE或什麼?你並沒有真正地說出「在我的應用程序中」沒有工作,所以更多的細節可能是一個好主意。 – 2014-10-31 13:23:19

+0

嗨戴夫。是的,我想這是一個不太好的代碼,也許只是爲了教育目的。刷新IDE無法正常工作,我甚至已經清理了我的gradle緩存,其他所有內容都可以在這個方向上使用。我能做的是爲客戶端生成一個令牌。我要在我的問題中粘貼兩個輸出,正確的和我的問題。 – 2014-10-31 17:06:38

+0

我不太確定我在看什麼。我以爲你說有編譯錯誤? – 2014-11-01 08:23:06

回答

0

撇開所提到的示例應用程序的奇怪實現,在Spring Boot中存在(或者是)一個問題,使得事情變得困難gh-1801。解決方法在那裏描述,也用於this sample