Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢捷峰
discovery
Commits
20fa4b1c
Commit
20fa4b1c
authored
Aug 30, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复spring.application.strategy.scan.packages和spring.application.strategy.feign.headers配置缺失而报错的异常
parent
b3d2268f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
discovery-plugin-strategy-starter-service/src/main/java/com/nepxion/discovery/plugin/strategy/service/configuration/ServiceStrategyAutoConfiguration.java
+13
-2
No files found.
discovery-plugin-strategy-starter-service/src/main/java/com/nepxion/discovery/plugin/strategy/service/configuration/ServiceStrategyAutoConfiguration.java
View file @
20fa4b1c
...
...
@@ -9,8 +9,10 @@ package com.nepxion.discovery.plugin.strategy.service.configuration;
* @version 1.0
*/
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.AutoConfigureBefore
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -29,15 +31,19 @@ import com.nepxion.discovery.plugin.strategy.service.constant.ServiceStrategyCon
@AutoConfigureBefore
(
RibbonClientConfiguration
.
class
)
@ConditionalOnProperty
(
value
=
StrategyConstant
.
SPRING_APPLICATION_STRATEGY_CONTROL_ENABLED
,
matchIfMissing
=
true
)
public
class
ServiceStrategyAutoConfiguration
{
@Value
(
"${"
+
ServiceStrategyConstant
.
SPRING_APPLICATION_STRATEGY_SCAN_PACKAGES
+
"}"
)
@Value
(
"${"
+
ServiceStrategyConstant
.
SPRING_APPLICATION_STRATEGY_SCAN_PACKAGES
+
"
:
}"
)
private
String
scanPackages
;
@Value
(
"${"
+
ServiceStrategyConstant
.
SPRING_APPLICATION_STRATEGY_FEIGN_HEADERS
+
"}"
)
@Value
(
"${"
+
ServiceStrategyConstant
.
SPRING_APPLICATION_STRATEGY_FEIGN_HEADERS
+
"
:
}"
)
private
String
feignHeaders
;
@Bean
@ConditionalOnProperty
(
value
=
ServiceStrategyConstant
.
SPRING_APPLICATION_STRATEGY_SCAN_PACKAGES
,
matchIfMissing
=
false
)
public
ServiceStrategyAutoScanProxy
serviceStrategyAutoScanProxy
()
{
if
(
StringUtils
.
isEmpty
(
scanPackages
))
{
throw
new
DiscoveryException
(
ServiceStrategyConstant
.
SPRING_APPLICATION_STRATEGY_SCAN_PACKAGES
+
" can't be empty, or you can't remove it"
);
}
if
(
ServiceStrategyConstant
.
EXCLUSION_SCAN_PACKAGES
.
contains
(
scanPackages
))
{
throw
new
DiscoveryException
(
"It can't scan packages for '"
+
ServiceStrategyConstant
.
EXCLUSION_SCAN_PACKAGES
+
"', please check '"
+
ServiceStrategyConstant
.
SPRING_APPLICATION_STRATEGY_SCAN_PACKAGES
+
"'"
);
}
...
...
@@ -48,6 +54,10 @@ public class ServiceStrategyAutoConfiguration {
@Bean
@ConditionalOnProperty
(
value
=
ServiceStrategyConstant
.
SPRING_APPLICATION_STRATEGY_SCAN_PACKAGES
,
matchIfMissing
=
false
)
public
ServiceStrategyInterceptor
serviceStrategyInterceptor
()
{
if
(
StringUtils
.
isEmpty
(
scanPackages
))
{
throw
new
DiscoveryException
(
ServiceStrategyConstant
.
SPRING_APPLICATION_STRATEGY_SCAN_PACKAGES
+
" can't be empty, or you can't remove it"
);
}
if
(
ServiceStrategyConstant
.
EXCLUSION_SCAN_PACKAGES
.
contains
(
scanPackages
))
{
throw
new
DiscoveryException
(
"It can't scan packages for '"
+
ServiceStrategyConstant
.
EXCLUSION_SCAN_PACKAGES
+
"', please check '"
+
ServiceStrategyConstant
.
SPRING_APPLICATION_STRATEGY_SCAN_PACKAGES
+
"'"
);
}
...
...
@@ -62,6 +72,7 @@ public class ServiceStrategyAutoConfiguration {
}
@Bean
@ConditionalOnMissingBean
public
DiscoveryEnabledAdapter
discoveryEnabledAdapter
()
{
return
new
DefaultDiscoveryEnabledAdapter
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment