0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OAuth2RestTemplateでClientHttpRequestInterceptorの設定を入れたい場合(Bean定義)

Posted at

SpringBootばかりでXMLConfigurationのサンプルがない!

SpringBootがメインになってくるとConfigurationクラスを作成してAnnotationベースで定義する場合が多いと思いますが、SpringMVCの場合はどうやって書いたらいいねん!で検証してみたので。

結論からいうと以下

applicationContext.xmlまたはspring-security.xmlまたはoauth-client.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://www.springframework.org/schema/security"
    xmlns:oauth2="http://www.springframework.org/schema/security/oauth2"
    xsi:schemaLocation="
        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2.xsd
    ">

  <!-- client, resourceなどは省略 -->

  <oauth2:rest-template id="oauth2RestTemplate" resource="grantResource" access-token-provider="tokenProvider">
    <property name="interceptors">
        <list>
          <ref bean="requestResponseLoggingInterceptor" />
        </list>
    </property>
  </oauth2:rest-template>

xsdの見方がわからず1時間ほどやられた、、、

@Beanの書き方は思い出したら書くかも

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?