Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
base
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
gyy
base
Commits
21e68e02
Commit
21e68e02
authored
Apr 21, 2022
by
HanChao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加,服务间互相调用 示例
parent
d3a585c2
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
223 additions
and
5 deletions
+223
-5
client-api/src/main/java/com/gzicloud/industry/client/export/ClientApiApplication.java
+1
-1
client-api/src/main/java/com/gzicloud/industry/client/export/controller/TestController.java
+10
-1
client-api/src/main/resources/application-dev.yml
+2
-2
client-export-server/pom.xml
+40
-0
client-export-server/src/main/java/com/gzicloud/industry/client/export/ClientExportApplication.java
+15
-0
client-export-server/src/main/java/com/gzicloud/industry/client/export/dubbo/call/CallService.java
+18
-0
client-export-server/src/main/java/com/gzicloud/industry/client/export/dubbo/impl/AcrossServiceImpl.java
+19
-0
client-export-server/src/main/java/com/gzicloud/industry/client/export/service/ICountryService.java
+7
-0
client-export-server/src/main/java/com/gzicloud/industry/client/export/service/impl/CountryServiceImpl.java
+19
-0
client-export-server/src/main/resources/application-dev.yml
+42
-0
client-export-server/src/main/resources/application-pro.yml
+16
-0
client-export-server/src/main/resources/application-test.yml
+16
-0
client-export-server/src/main/resources/application.yml
+6
-0
client-facade/src/main/java/com/gzicloud/industry/client/facade/service/IAcrossService.java
+10
-0
client-resume-server/src/main/java/com/gzicloud/industry/client/resume/dubbo/impl/TestServiceImpl.java
+1
-1
pom.xml
+1
-0
No files found.
client-api/src/main/java/com/gzicloud/industry/client/
api
/ClientApiApplication.java
→
client-api/src/main/java/com/gzicloud/industry/client/
export
/ClientApiApplication.java
View file @
21e68e02
package
com
.
gzicloud
.
industry
.
client
.
api
;
package
com
.
gzicloud
.
industry
.
client
.
export
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
...
...
client-api/src/main/java/com/gzicloud/industry/client/
api
/controller/TestController.java
→
client-api/src/main/java/com/gzicloud/industry/client/
export
/controller/TestController.java
View file @
21e68e02
package
com
.
gzicloud
.
industry
.
client
.
api
.
controller
;
package
com
.
gzicloud
.
industry
.
client
.
export
.
controller
;
import
com.gzicloud.industry.client.facade.service.IAcrossService
;
import
com.gzicloud.industry.client.facade.service.ITestService
;
import
org.apache.dubbo.config.annotation.DubboReference
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -13,6 +14,9 @@ public class TestController {
@DubboReference
private
ITestService
resumeService
;
@DubboReference
private
IAcrossService
acrossService
;
@GetMapping
(
"/simple"
)
public
String
simple
(
String
id
)
{
return
resumeService
.
test
(
Long
.
valueOf
(
id
));
...
...
@@ -23,4 +27,9 @@ public class TestController {
return
"测试:"
+
id
;
}
@GetMapping
(
"/across"
)
public
String
across
(
String
id
)
{
return
acrossService
.
acrossServer
(
Long
.
valueOf
(
id
));
}
}
client-api/src/main/resources/application-dev.yml
View file @
21e68e02
...
...
@@ -16,7 +16,7 @@ dubbo:
protocol
:
# dubbo 协议
name
:
dubbo
# dubbo 协议端口( -1 表示自增端口,从 20880 开始)
#
# dubbo 协议端口( -1 表示自增端口,从 20880 开始)
port
:
-1
host
:
127.0.0.1
registry
:
...
...
@@ -24,4 +24,4 @@ dubbo:
address
:
spring-cloud://localhost
cloud
:
# 订阅服务提供方的应用列表,订阅多个服务提供者使用 "," 连接
subscribed-services
:
industry-client-resume-server
subscribed-services
:
industry-client-resume-server
,industry-client-export-server
client-export-server/pom.xml
0 → 100644
View file @
21e68e02
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
industry-cloud-parent
</artifactId>
<groupId>
org.gzicloud.industry
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
client-export-server
</artifactId>
<properties>
<mybatis-plus.version>
3.4.1
</mybatis-plus.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.gzicloud.industry
</groupId>
<artifactId>
client-facade
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<!-- MyBatis-Plus -->
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
${mybatis-plus.version}
</version>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<scope>
runtime
</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
client-export-server/src/main/java/com/gzicloud/industry/client/export/ClientExportApplication.java
0 → 100644
View file @
21e68e02
package
com
.
gzicloud
.
industry
.
client
.
export
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
@EnableDiscoveryClient
@SpringBootApplication
public
class
ClientExportApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
ClientExportApplication
.
class
,
args
);
}
}
client-export-server/src/main/java/com/gzicloud/industry/client/export/dubbo/call/CallService.java
0 → 100644
View file @
21e68e02
package
com
.
gzicloud
.
industry
.
client
.
export
.
dubbo
.
call
;
import
com.gzicloud.industry.client.facade.service.ITestService
;
import
org.apache.dubbo.config.annotation.DubboReference
;
import
org.springframework.stereotype.Service
;
@Service
public
class
CallService
{
@DubboReference
private
ITestService
testService
;
public
String
call
(
Long
id
)
{
return
"服务间相互调用"
+
testService
.
test
(
id
);
}
}
client-export-server/src/main/java/com/gzicloud/industry/client/export/dubbo/impl/AcrossServiceImpl.java
0 → 100644
View file @
21e68e02
package
com
.
gzicloud
.
industry
.
client
.
export
.
dubbo
.
impl
;
import
com.gzicloud.industry.client.export.service.ICountryService
;
import
com.gzicloud.industry.client.facade.service.IAcrossService
;
import
org.apache.dubbo.config.annotation.DubboService
;
import
javax.annotation.Resource
;
@DubboService
public
class
AcrossServiceImpl
implements
IAcrossService
{
@Resource
private
ICountryService
countryService
;
@Override
public
String
acrossServer
(
Long
id
)
{
return
countryService
.
getCountry
(
id
);
}
}
client-export-server/src/main/java/com/gzicloud/industry/client/export/service/ICountryService.java
0 → 100644
View file @
21e68e02
package
com
.
gzicloud
.
industry
.
client
.
export
.
service
;
public
interface
ICountryService
{
String
getCountry
(
Long
id
);
}
client-export-server/src/main/java/com/gzicloud/industry/client/export/service/impl/CountryServiceImpl.java
0 → 100644
View file @
21e68e02
package
com
.
gzicloud
.
industry
.
client
.
export
.
service
.
impl
;
import
com.gzicloud.industry.client.export.dubbo.call.CallService
;
import
com.gzicloud.industry.client.export.service.ICountryService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
@Service
public
class
CountryServiceImpl
implements
ICountryService
{
@Resource
private
CallService
callService
;
@Override
public
String
getCountry
(
Long
id
)
{
return
callService
.
call
(
id
);
}
}
client-export-server/src/main/resources/application-dev.yml
0 → 100644
View file @
21e68e02
spring
:
cloud
:
nacos
:
discovery
:
server-addr
:
localhost:8848
#Nacos 链接地址
namespace
:
2fe44b66-8b9b-4df7-ae48-b8763132c498
#Nacos 命名空间ID
config
:
server-addr
:
localhost:8848
#Nacos 链接地址
namespace
:
2fe44b66-8b9b-4df7-ae48-b8763132c498
#Nacos 命名空间ID
group
:
DEFAULT_GROUP
# 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
file-extension
:
yml
#默认properties
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
username
:
hanchao
password
:
123123
url
:
jdbc:mysql://localhost:3306/db2020?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2B8
hikari
:
minimum-idle
:
10
maximum-pool-size
:
15
connection-timeout
:
1000
mybatis-plus
:
configuration
:
log-impl
:
org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations
:
classpath:/mapper/*Mapper.xml
dubbo
:
scan
:
# dubbo 服务扫描基准包
base-packages
:
com.gzicloud.industry.client.export
protocol
:
# dubbo 协议
name
:
dubbo
# dubbo 协议端口( -1 表示自增端口,从 20880 开始)
port
:
-1
host
:
127.0.0.1
registry
:
# 挂载到 Spring Cloud 的注册中心
address
:
spring-cloud://localhost
cloud
:
subscribed-services
:
industry-client-resume-server
\ No newline at end of file
client-export-server/src/main/resources/application-pro.yml
0 → 100644
View file @
21e68e02
server
:
port
:
8003
spring
:
application
:
name
:
industry-client-resume-server
cloud
:
nacos
:
discovery
:
server-addr
:
localhost:8848
#Nacos 链接地址
namespace
:
2fe44b66-8b9b-4df7-ae48-b8763132c498
#Nacos 命名空间ID
config
:
server-addr
:
localhost:8848
#Nacos 链接地址
namespace
:
2fe44b66-8b9b-4df7-ae48-b8763132c498
#Nacos 命名空间ID
group
:
DEFAULT_GROUP
# 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
file-extension
:
yml
#默认properties
\ No newline at end of file
client-export-server/src/main/resources/application-test.yml
0 → 100644
View file @
21e68e02
server
:
port
:
8003
spring
:
application
:
name
:
industry-client-resume-server
cloud
:
nacos
:
discovery
:
server-addr
:
localhost:8848
#Nacos 链接地址
namespace
:
2fe44b66-8b9b-4df7-ae48-b8763132c498
#Nacos 命名空间ID
config
:
server-addr
:
localhost:8848
#Nacos 链接地址
namespace
:
2fe44b66-8b9b-4df7-ae48-b8763132c498
#Nacos 命名空间ID
group
:
DEFAULT_GROUP
# 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
file-extension
:
yml
#默认properties
\ No newline at end of file
client-export-server/src/main/resources/application.yml
0 → 100644
View file @
21e68e02
spring
:
profiles
:
active
:
dev
application
:
name
:
industry-client-export-server
\ No newline at end of file
client-facade/src/main/java/com/gzicloud/industry/client/facade/service/IAcrossService.java
0 → 100644
View file @
21e68e02
package
com
.
gzicloud
.
industry
.
client
.
facade
.
service
;
/**
* 测试服务间调用
*/
public
interface
IAcrossService
{
String
acrossServer
(
Long
id
);
}
client-resume-server/src/main/java/com/gzicloud/industry/client/resume/dubbo/TestServiceImpl.java
→
client-resume-server/src/main/java/com/gzicloud/industry/client/resume/dubbo/
impl/
TestServiceImpl.java
View file @
21e68e02
package
com
.
gzicloud
.
industry
.
client
.
resume
.
dubbo
;
package
com
.
gzicloud
.
industry
.
client
.
resume
.
dubbo
.
impl
;
import
com.gzicloud.industry.client.facade.service.ITestService
;
import
com.gzicloud.industry.client.resume.service.IResumeService
;
...
...
pom.xml
View file @
21e68e02
...
...
@@ -12,6 +12,7 @@
<module>
client-api
</module>
<module>
client-resume-server
</module>
<module>
client-facade
</module>
<module>
client-export-server
</module>
</modules>
<packaging>
pom
</packaging>
...
...
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