mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-09-18 17:48:03 +08:00
新增 Dubbo 集成插件
This commit is contained in:
13
sa-token-demo/sa-token-demo-dubbo-provider/.gitignore
vendored
Normal file
13
sa-token-demo/sa-token-demo-dubbo-provider/.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
target/
|
||||
.project
|
||||
.classpath
|
||||
.settings
|
||||
|
||||
/.idea/
|
||||
|
||||
node_modules/
|
||||
bin/
|
||||
.settings/
|
||||
unpackage/
|
||||
/.apt_generated/
|
||||
/.apt_generated_tests/
|
75
sa-token-demo/sa-token-demo-dubbo-provider/pom.xml
Normal file
75
sa-token-demo/sa-token-demo-dubbo-provider/pom.xml
Normal file
@@ -0,0 +1,75 @@
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.pj</groupId>
|
||||
<artifactId>sa-token-demo-dubbo-provider</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
<!-- SpringBoot -->
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.3.3.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<!-- 指定一些属性 -->
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringBoot Web模块 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Sa-Token -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<version>1.27.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Sa-Token整合 Redis (使用jackson序列化方式) -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-dao-redis-jackson</artifactId>
|
||||
<version>1.27.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Dubbo -->
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-starter</artifactId>
|
||||
<version>2.7.11</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Dubbo 注册到 Nacos -->
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-registry-nacos</artifactId>
|
||||
<version>2.7.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-client</artifactId>
|
||||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Sa-Token 整合 Dubbo -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-context-dubbo</artifactId>
|
||||
<version>1.27.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@@ -0,0 +1,22 @@
|
||||
package com.pj;
|
||||
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* Dubbo 服务提供端
|
||||
*
|
||||
* @author kong
|
||||
*
|
||||
*/
|
||||
@EnableDubbo
|
||||
@SpringBootApplication
|
||||
public class ProviderApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ProviderApplication.class, args);
|
||||
System.out.println("ProviderApplication 启动成功");
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.pj.more;
|
||||
|
||||
public interface DemoService {
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @param loginId 账号id
|
||||
*/
|
||||
void doLogin(Object loginId);
|
||||
|
||||
/**
|
||||
* 判断是否登录,打印状态
|
||||
*/
|
||||
void isLogin(String str);
|
||||
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.pj.more;
|
||||
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
|
||||
@DubboService()
|
||||
public class DemoServiceImpl implements DemoService {
|
||||
|
||||
@Override
|
||||
public void doLogin(Object loginId) {
|
||||
StpUtil.login(loginId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isLogin(String str) {
|
||||
System.out.println(str);
|
||||
System.out.println("Token值:" + StpUtil.getTokenValue());
|
||||
System.out.println("是否登录:" + StpUtil.isLogin());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,38 @@
|
||||
server:
|
||||
# 端口号
|
||||
port: 8080
|
||||
|
||||
spring:
|
||||
# redis配置
|
||||
redis:
|
||||
# Redis数据库索引(默认为0)
|
||||
database: 0
|
||||
# Redis服务器地址
|
||||
host: 127.0.0.1
|
||||
# Redis服务器连接端口
|
||||
port: 6379
|
||||
# Redis服务器连接密码(默认为空)
|
||||
password:
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
|
||||
# Dubbo
|
||||
dubbo:
|
||||
# 服务名
|
||||
application:
|
||||
name: dubbo-provider-demo
|
||||
# 扫描包
|
||||
scan:
|
||||
base-packages: com.pj
|
||||
# 注册中心地址
|
||||
registry:
|
||||
address: nacos://127.0.0.1:8001
|
||||
# 协议
|
||||
protocol:
|
||||
name: dubbo
|
||||
port: 12345
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user