Commit af14582f authored by 杨锐's avatar 杨锐

修复@Bean低级问题。

parent 2d68647d
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>commons-parent</artifactId> <artifactId>commons-parent</artifactId>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<version>0.3.1</version> <version>0.3.2</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -3,10 +3,14 @@ package cn.quantgroup.tech.brave.configuration; ...@@ -3,10 +3,14 @@ package cn.quantgroup.tech.brave.configuration;
import cn.quantgroup.tech.brave.interceptor.*; import cn.quantgroup.tech.brave.interceptor.*;
import cn.quantgroup.tech.brave.interceptor.impl.*; import cn.quantgroup.tech.brave.interceptor.impl.*;
import cn.quantgroup.tech.brave.job.TokenJob; import cn.quantgroup.tech.brave.job.TokenJob;
import okhttp3.Interceptor;
import org.apache.http.HttpRequestInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestInterceptor;
@Configuration @Configuration
public class AuthAutoConfiguration { public class AuthAutoConfiguration {
...@@ -14,22 +18,37 @@ public class AuthAutoConfiguration { ...@@ -14,22 +18,37 @@ public class AuthAutoConfiguration {
@Configuration @Configuration
public static class NoAuthConfiguration { public static class NoAuthConfiguration {
@Bean @Configuration
@ConditionalOnClass(HttpRequestInterceptor.class)
@ConditionalOnMissingBean(HttpClientRequestInterceptor.class) @ConditionalOnMissingBean(HttpClientRequestInterceptor.class)
public HttpClientRequestInterceptor httpClientRequestInterceptor() { public static class HttpRequestInterceptorEnable {
return new HttpClientNoAuthRequestInterceptor();
@Bean
public HttpClientRequestInterceptor httpClientRequestInterceptor() {
return new HttpClientNoAuthRequestInterceptor();
}
} }
@Bean @Configuration
@ConditionalOnClass(Interceptor.class)
@ConditionalOnMissingBean(OkHttpClientInterceptor.class) @ConditionalOnMissingBean(OkHttpClientInterceptor.class)
public OkHttpClientInterceptor okHttpClientInterceptor() { public static class InterceptorEnable {
return new OkHttpClientNoAuthInterceptor();
@Bean
public OkHttpClientInterceptor okHttpClientInterceptor() {
return new OkHttpClientNoAuthInterceptor();
}
} }
@Bean @Configuration
@ConditionalOnClass(ClientHttpRequestInterceptor.class)
@ConditionalOnMissingBean(RestTemplateRequestInterceptor.class) @ConditionalOnMissingBean(RestTemplateRequestInterceptor.class)
public RestTemplateRequestInterceptor restTemplateRequestInterceptor() { public static class ClientHttpRequestInterceptorEnable {
return new RestTemplateNoAuthRequestInterceptor();
@Bean
public RestTemplateRequestInterceptor restTemplateRequestInterceptor() {
return new RestTemplateNoAuthRequestInterceptor();
}
} }
} }
...@@ -37,22 +56,37 @@ public class AuthAutoConfiguration { ...@@ -37,22 +56,37 @@ public class AuthAutoConfiguration {
@ConditionalOnProperty(prefix = "tech.auth", name = "enabled", havingValue = "true") @ConditionalOnProperty(prefix = "tech.auth", name = "enabled", havingValue = "true")
public static class AuthConfiguration { public static class AuthConfiguration {
@Bean @Configuration
@ConditionalOnClass(HttpRequestInterceptor.class)
@ConditionalOnProperty(prefix = "tech.auth", name = {"http", "clientId", "secret", "tokenUrl"}) @ConditionalOnProperty(prefix = "tech.auth", name = {"http", "clientId", "secret", "tokenUrl"})
public HttpClientRequestInterceptor httpClientRequestInterceptor() { public static class HttpRequestInterceptorEnable {
return new HttpClientAuthRequestInterceptor();
@Bean
public HttpClientRequestInterceptor httpClientRequestInterceptor() {
return new HttpClientAuthRequestInterceptor();
}
} }
@Bean @Configuration
@ConditionalOnClass(Interceptor.class)
@ConditionalOnProperty(prefix = "tech.auth", name = {"http", "clientId", "secret", "tokenUrl"}) @ConditionalOnProperty(prefix = "tech.auth", name = {"http", "clientId", "secret", "tokenUrl"})
public OkHttpClientInterceptor okHttpClientInterceptor() { public static class InterceptorEnable {
return new OkHttpClientAuthInterceptor();
@Bean
public OkHttpClientInterceptor okHttpClientInterceptor() {
return new OkHttpClientAuthInterceptor();
}
} }
@Bean @Configuration
@ConditionalOnClass(ClientHttpRequestInterceptor.class)
@ConditionalOnProperty(prefix = "tech.auth", name = {"http", "clientId", "secret", "tokenUrl"}) @ConditionalOnProperty(prefix = "tech.auth", name = {"http", "clientId", "secret", "tokenUrl"})
public RestTemplateRequestInterceptor restTemplateRequestInterceptor() { public static class ClientHttpRequestInterceptorEnable {
return new RestTemplateAuthRequestInterceptor();
@Bean
public RestTemplateRequestInterceptor restTemplateRequestInterceptor() {
return new RestTemplateAuthRequestInterceptor();
}
} }
@Bean @Bean
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>commons-parent</artifactId> <artifactId>commons-parent</artifactId>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<version>0.3.1</version> <version>0.3.2</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>commons-parent</artifactId> <artifactId>commons-parent</artifactId>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<version>0.3.1</version> <version>0.3.2</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>commons-parent</artifactId> <artifactId>commons-parent</artifactId>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<version>0.3.1</version> <version>0.3.2</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>commons-parent</artifactId> <artifactId>commons-parent</artifactId>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<version>0.3.1</version> <version>0.3.2</version>
</parent> </parent>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<artifactId>enoch-agent-spring-boot-starter</artifactId> <artifactId>enoch-agent-spring-boot-starter</artifactId>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>commons-parent</artifactId> <artifactId>commons-parent</artifactId>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<version>0.3.1</version> <version>0.3.2</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<artifactId>commons-parent</artifactId> <artifactId>commons-parent</artifactId>
<version>0.3.1</version> <version>0.3.2</version>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<lombok.version>1.16.20</lombok.version> <lombok.version>1.16.20</lombok.version>
<guava.version>23.0</guava.version> <guava.version>23.0</guava.version>
<apollo.client.version>0.10.2</apollo.client.version> <apollo.client.version>0.10.2</apollo.client.version>
<common.parent.version>0.3.1</common.parent.version> <common.parent.version>0.3.2</common.parent.version>
</properties> </properties>
<dependencies> <dependencies>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>commons-parent</artifactId> <artifactId>commons-parent</artifactId>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<version>0.3.1</version> <version>0.3.2</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment