提交 2cf3c428 编写于 作者: X xiongchun

更新说明文档

上级 8b0e03fe
pangu-cache-spring-boot-starter
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
\ No newline at end of file
pangu-common
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
\ No newline at end of file
pangu-dubbo-spring-boot-starter
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
......@@ -2,4 +2,12 @@
1. 如何使用两级缓存。
**更多开发指南请参考盘古平台相关文档说明。**
\ No newline at end of file
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
\ No newline at end of file
......@@ -2,4 +2,12 @@
1. 如何使用原生的一级缓存RedisTemplate API。
**更多开发指南请参考盘古平台相关文档说明。**
\ No newline at end of file
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
\ No newline at end of file
#### :mushroom: 范例演示功能
1. 使用本地配置文件的方式进行应用配置
> :fa-thumbs-o-up: 为了满足一些特殊的场景,我们可以使用这种基于本地配置文件的开发模式。但使用Nacos配置中心对参数进行统一配置和管理才是盘古应用的标准开发模式,详情请参阅范例`pangu-examples-config-remote-nacos`。
### 介绍
#### :four_leaf_clover: 基于本地配置文件的开发模式
- **第一步:安装pom依赖**
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
```xml
<parent>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-parent</artifactId>
<version>latest.version.xxx</version>
<relativePath/>
</parent>
```
```xml
<dependency>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-spring-boot-starter</artifactId>
</dependency>
```
### 更多资源
- **第二步:本地配置文件**
```properties
spring.application.name=pangu-examples-config-local
demo.app.id=1000001
```
- **第三步:使用@NacosValue注解获取参数值**
```java
@SpringBootApplication
public class LocalConfigurationApplication {
public static void main(String[] args) {
PanGuApplicationBuilder.init(LocalConfigurationApplication.class).run(args);
}
@Component
public class LocalConfiguration {
@NacosValue("${demo.app.id}")
private String appId;
@NacosValue("${spring.application.name}")
private String appName;
@PostConstruct
@Scheduled
public void execute() {
log.info("演示获取本地配置数据");
log.info("参数appId:{}", appId);
log.info("参数appName:{}", appName);
}
}
}
```
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
......@@ -2,73 +2,12 @@
1. 如何获取Nacos配置中心的远程配置参数。
2. 参数值修改后动态刷新Nacos配置数据。
> :fa-thumbs-o-up: 使用Nacos配置中心对参数进行统一配置和管理是盘古应用的标准开发模式。当然,盘古开发框架也可以支持本地配置的开发模式,具体请参阅本地配置模式开发的相关范例。
### 介绍
#### :four_leaf_clover: 如何获取配置中心的配置参数
- **第一步:安装pom依赖**
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
```xml
<parent>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-parent</artifactId>
<version>latest.version.xxx</version>
<relativePath/>
</parent>
```
```xml
<dependency>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-spring-boot-starter</artifactId>
</dependency>
```
### 更多资源
- **第二步:模块的本地配置文件模版**
```properties
spring.application.name=pangu-examples-config-remote-nacos
spring.profiles.active=${spring.profiles.active:dev}
nacos.config.bootstrap.enable=true
nacos.config.bootstrap.log-enable=true
nacos.config.auto-refresh=true
#对应Nacos配置中心的命名空间ID
nacos.config.namespace=${nacos.namespace:pangu-dev}
nacos.config.server-addr=${nacos.server-addr:127.0.0.1:8848}
nacos.config.type=properties
nacos.config.data-id=${spring.application.name}.properties
```
- **第三步:在Nacos配置中心新建配置**
1. 在配置中心新建命名空间,命名空间ID与本地配置文件`application.properties`中的参数`nacos.config.namespace`值一致。(pangu-dev)
2.`pangu-dev`命名空间下,新建配置。DataId与本地配置文件`application.properties`中的参数`nacos.config.data-id`值一致。(pangu-examples-config-remote-nacos)配置如下参数信息。
```properties
# 演示参数配置
demo.app.id=XC001001
demo.app.name=盘古开发框架
demo.app.author=普蓝开源社区
logging.level.root=INFO
logging.level.com.gitee.pulanos.pangu=INFO
logging.level.com.alibaba.nacos.client.config.impl.ClientWorker=WARN
```
- **第四步:使用@NacosValue注解获取参数值**
```java
/**
* 开启 autoRefreshed配置项, 可以实现参数的动态刷新
*/
@NacosValue(value = "${demo.app.id}")
private String appId;
@NacosValue(value = "${demo.app.name}", autoRefreshed = true)
private String appName;
@NacosValue(value = "${demo.app.author}", autoRefreshed = true)
private String appAuthor;
```
#### :blossom: 动态刷新配置数据
登录Nacos配置中心,修改对应参数值,查看控制台正在循环输出日志的变化情况。以验证动态刷新配置数据功能。
```
2021-09-15 12:28:30.005 INFO : 参数appId:XC001001
2021-09-15 12:28:30.005 INFO : 参数appName:盘古开发框架
2021-09-15 12:28:30.005 INFO : 参数appAuthor:普蓝开源社区
```
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
......@@ -4,196 +4,12 @@
2. 使用MybatisPlus的API接口操作数据库的常用方法。
3. 分页查询和手工映复杂SQL的方法。
> :tw-1f493: 温馨提示:本范例只演示了一些基本和常用的数据库相关操作。更多用法请直接参阅[MybatisPlus文档](https://mp.baomidou.com/guide/)。
### 介绍
> :tw-1f4a3: 特别提示:经过我们对MybatisPlus框架的长期使用和总结,特给出如下2个“最佳实践”:(1)、使用盘古自带的代码成插件生成相关代码。(2)、只使用MyabtisPlus的Mapper CRUD接口,不建议使用Service CRUD接口
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架
#### :four_leaf_clover: 安装依赖和参数配置
### 更多资源
- 安装依赖
```xml
<parent>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-parent</artifactId>
<version>latest.version.xxx</version>
<relativePath/>
</parent>
```
```xml
<dependency>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-jdbc-spring-boot-starter</artifactId>
</dependency>
```
- 配置参数
```properties
spring.application.name=pangu-examples-crud
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/pangu-examples?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&allowMultiQueries=true&useSSL=false
spring.datasource.username=root
spring.datasource.password=root123456
mybatis-plus.mapperLocations=classpath*:/mapper/**/*.xml
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
# 分页SQL方言数据库类型标识(缺省:自动识别)
pangu.jdbc.db-type=mysql
```
#### :four_leaf_clover: 如何使用盘古代码生成Maven插件生成DAO相关Mapper接口和Entity实体类
- 安装Maven插件
```
<plugin>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-generator-maven-plugin</artifactId>
<version>5.0.6</version>
<configuration>
<url>jdbc:mysql://127.0.0.1:3306/pangu-showcases</url>
<user>root</user>
<password>root123456</password>
<tables>user</tables>
<author>普蓝开源社区</author>
<!-- 可以使用绝对路径 -->
<entityFilePath>${project.basedir}/src/main/java/com/gitee/pulanos/pangu/showcases/crud/dao/entity</entityFilePath>
<entityPackageName>com.gitee.pulanos.pangu.showcases.crud.dao.entity</entityPackageName>
<mapperFilePath>${project.basedir}/src/main/java/com/gitee/pulanos/pangu/showcases/crud/dao/mapper</mapperFilePath>
<mapperPackageName>com.gitee.pulanos.pangu.showcases.crud.dao.mapper</mapperPackageName>
</configuration>
</plugin>
```
- 执行 `mvn pangu:generate`生成代码,查看控制台生成文件的输出信息。
#### :green_apple: 使用MybatisPlus的API接口操作数据库的常用方法
```
public int aInsert() {
log.info("插入数据...");
UserEntity userEntity = new UserEntity();
userEntity.setName("XC").setAge(18).setUserType("1");
int row = userMapper.insert(userEntity);
log.info("成功插入{}条数据。{}", row, userEntity);
return row;
}
@Transactional(rollbackFor = RuntimeException.class)
public void aUpdate() {
log.info("更新数据...");
//方式1
userMapper.updateById(new UserEntity().setId(1L).setName("XC2"));
//方式2
LambdaUpdateWrapper<UserEntity> updateWrapper = Wrappers.lambdaUpdate();
updateWrapper.set(UserEntity::getAge, 100);
updateWrapper.eq(UserEntity::getId, 2L);
userMapper.update(null, updateWrapper);
//方式2简写
userMapper.update(null, Wrappers.<UserEntity>lambdaUpdate().set(UserEntity::getName, "XC2").eq(UserEntity::getId, 3L));
//方式3
UserEntity userEntity = new UserEntity();
userEntity.setName("XC2");
userMapper.update(userEntity, Wrappers.<UserEntity>lambdaUpdate().eq(UserEntity::getId, 4L));
}
public void aDelete() {
log.info("删除数据...");
//方式1
userMapper.deleteById(1000L);
//方式2
userMapper.deleteBatchIds(Arrays.asList(1000L, 1001L));
//方式3
userMapper.delete(Wrappers.<UserEntity>lambdaQuery().ge(UserEntity::getAge, 150));
//方式4
userMapper.deleteById(new UserEntity().setId(2000L));
}
public void aSelect() {
log.info("查询数据...");
//方式1
UserEntity userEntity = userMapper.selectById(1L);
//方式2
UserEntity userEntity1 = userMapper.selectOne(Wrappers.<UserEntity>lambdaQuery().eq(UserEntity::getId, 1L));
//方式3
List<UserEntity> userEntities = userMapper.selectBatchIds(Arrays.asList(1L, 2L));
//方式4
Integer age = 100;
LambdaQueryWrapper<UserEntity> lambdaQueryWrapper = Wrappers.lambdaQuery();
//动态组合查询条件的简便写法
lambdaQueryWrapper.between(ObjectUtil.isNotEmpty(age), UserEntity::getAge, 1, age);
lambdaQueryWrapper.eq(UserEntity::getUserType, "1");
lambdaQueryWrapper.orderByDesc(UserEntity::getId);
List<UserEntity> userEntities1 = userMapper.selectList(lambdaQueryWrapper);
//方式5
QueryWrapper<UserEntity> queryWrapper = Wrappers.query();
queryWrapper.select("id").ge("age", 10).orderByDesc("age");
List<Long> ids = (List<Long>) (List) userMapper.selectObjs(queryWrapper);
//方式6
List<Map<String, Object>> userMaps = userMapper.selectMaps(Wrappers.<UserEntity>lambdaQuery().eq(UserEntity::getUserType, "1"));
//方式7 count
Long cnt = userMapper.selectCount(Wrappers.<UserEntity>lambdaQuery().le(UserEntity::getGmtCreate, DateUtil.date()));
//方式8 group
QueryWrapper<UserEntity> queryWrapper1 = Wrappers.query();
queryWrapper1.select("age, count(id) as cnt").groupBy("age");
List<Map<String, Object>> mapList = userMapper.selectMaps(queryWrapper1);
}
```
#### :cactus: 分页查询和手工映复杂SQL的方法
- 分页查询
```
public void aPageQuery(){
log.info("MyBatisPlus API 分页查询数据...");
Page page = new Page<UserEntity>(1,3);
userMapper.selectPage(page, Wrappers.<UserEntity>lambdaQuery().ge(UserEntity::getAge, 10).orderByAsc(UserEntity::getId));
Console.log("总数:{}", page.getTotal());
List<UserEntity> userEntities = page.getRecords();
userEntities.forEach(System.out::println);
}
public void bPageQuery(){
log.info("自定义SQL映射分页查询数据...");
Page page = new Page<UserEntity>(1,3);
Map<String, Object> params = Maps.newHashMap();
params.put("userType", "1");
List<UserEntity> userEntities = crudMapper.listUsersByPage(page, params);
Console.log("总数:{}", page.getTotal());
userEntities.forEach(System.out::println);
}
public void cPageQuery(){
log.info("自定义SQL映射分页查询数据...");
Page page = new Page<Map<String, Object>>(1,3);
String userType = "1";
List<Map<String, Object>> userMaps = crudMapper.listUserMapsByPage(page, userType);
Console.log("总数:{}", page.getTotal());
userMaps.forEach(System.out::println);
}
```
- 手工映射复杂SQL
针对复杂统计类SQL可以通过如下方式手工在XML中写SQL语句。
```
public void bSelect() {
log.info("自定义SQL映射查询数据...");
Map<String, Object> params = Maps.newHashMap();
params.put("userType", "1");
List<UserEntity> userEntities = crudMapper.listUsersByMap(params);
userEntities.forEach(System.out::println);
}
```
> :tw-1f493: 温馨提示:更多代码请直接查看 [ **CrudService.java** ](https://gitee.com/pulanos/pangu-showcases/blob/master/pangu-showcases-crud/src/main/java/com/gitee/pulanos/pangu/showcases/crud/service/CrudService.java)
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
\ No newline at end of file
......@@ -2,4 +2,12 @@
1. 开发Dubbo服务时接口文件和POJO相关类的打包模块。
> 通过maven依赖将接口模块引入到dubbo服务提供者模块和消费者模块中。
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
......@@ -2,77 +2,12 @@
1. 如何调用一个已注册到Nacos服务中心的Dubbo远程服务
#### :four_leaf_clover: 如何开发一个Dubbo远程服务并将其注册到Nacos服务中心
- **第一步: 增加依赖**
```xml
<dependency>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-dubbo-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-examples-dubbo-api</artifactId>
<version>1.0.0</version>
</dependency>
```
- **第二步:参数配置**
- 本地参数配置
```properties
spring.application.name=pangu-examples-dubbo-service
spring.profiles.active=${spring.profiles.active:dev}
nacos.config.bootstrap.enable=true
nacos.config.bootstrap.log-enable=true
nacos.config.auto-refresh=true
#对应Nacos配置中心的命名空间ID
nacos.config.namespace=${nacos.namespace:pangu-dev}
nacos.config.server-addr=${nacos.server-addr:127.0.0.1:8848}
nacos.config.type=properties
nacos.config.data-id=${spring.application.name}.properties
```
- 远程参数配置(Nacos配置中心)
```properties
dubbo.protocol.name=dubbo
dubbo.protocol.port=20880
dubbo.consumer.timeout=5000
dubbo.registry.address=nacos://${nacos.config.server-addr}?namespace=${nacos.config.namespace}
dubbo.consumer.check=false
logging.level.root=INFO
logging.level.com.gitee.pulanos.pangu=INFO
logging.level.com.alibaba.nacos.client.config.impl.ClientWorker=WARN
```
- **第三步:调用远程服务接口**
### 介绍
```
@Component
public class UserAdminManager {
@Reference(version = "1.0.0", group = "pangu-examples-dubbo-service")
private UserService userService;
public void findUserEntityById(Long id){
log.info("开始Dubbo远程调用...");
UserEntity userEntity = userService.findUserEntity(id);
log.info("[OK] 调用成功 {}", userEntity);
}
}
```
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
- **第四步:启动类**
### 更多资源
``` java
@EnableDubbo
@SpringBootApplication
@ComponentScan({"com.gitee.pulanos.pangu.showcases.dubbo"})
public class DubboConsumerApplication {
public static void main(String[] args) {
PanGuApplicationBuilder.init(DubboConsumerApplication.class).run(args);
}
}
```
> :fa-bullhorn: 运行测试类参数设置 :`-Dnacos.server-addr=ip:port`
(根据实际情况设置启动参数)
\ No newline at end of file
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
\ No newline at end of file
#### :mushroom: 本范例演示功能
1. 如何开发一个能和盘古网关系统集成的后端Dubbo应用。
**更多开发指南请参考盘古平台相关文档说明。**
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
......@@ -2,81 +2,12 @@
1. 如何开发一个Dubbo远程服务并将其注册到Nacos服务中心
#### :four_leaf_clover: 如何开发一个Dubbo远程服务并将其注册到Nacos服务中心
- **第一步: 增加依赖**
```xml
<dependency>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-dubbo-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-examples-dubbo-api</artifactId>
<version>1.0.0</version>
</dependency>
```
- **第二步:参数配置**
- 本地参数配置
```properties
spring.application.name=pangu-examples-dubbo-service
spring.profiles.active=${spring.profiles.active:dev}
nacos.config.bootstrap.enable=true
nacos.config.bootstrap.log-enable=true
nacos.config.auto-refresh=true
#对应Nacos配置中心的命名空间ID
nacos.config.namespace=${nacos.namespace:pangu-dev}
nacos.config.server-addr=${nacos.server-addr:127.0.0.1:8848}
nacos.config.type=properties
nacos.config.data-id=${spring.application.name}.properties
```
- 远程参数配置(Nacos配置中心)
```
dubbo.protocol.name=dubbo
dubbo.protocol.port=20880
dubbo.consumer.timeout=5000
dubbo.registry.address=nacos://${nacos.config.server-addr}?namespace=${nacos.config.namespace}
dubbo.consumer.check=false
logging.level.root=INFO
logging.level.com.gitee.pulanos.pangu=INFO
logging.level.com.alibaba.nacos.client.config.impl.ClientWorker=WARN
```
- **第三步:实现远程服务接口 `UserServiceImpl`**
### 介绍
```
@Service(version = "1.0.0", group = "pangu-showcases-dubbo-service")
public class UserServiceImpl implements UserService {
@Override
public UserEntity findUserEntity(Long id) {
log.info("参数ID:{}", id);
UserEntity userEntity = new UserEntity();
userEntity.setId(id);
userEntity.setName("云南码农大熊");
return userEntity;
}
}
```
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
- **第四步:启动类**
### 更多资源
```java
@EnableDubbo
@SpringBootApplication
public class DubboProviderApplication {
public static void main(String[] args) {
PanGuApplicationBuilder.init(DubboProviderApplication.class).run(args);
}
}
```
> :fa-bullhorn: 启动参数设置 :`-Dnacos.server-addr=ip:port`
(根据实际情况设置启动参数)
- **第五步:查看服务注册中心已注册的Dubbo服务**
成功启动应用后,即可在Naocs服务注册中心页查看效果。如下图所示。
![盘古开发Dubbo服务](https://images.gitee.com/uploads/images/2021/1101/095150_5b057bdd_431745.png "盘古开发Dubbo服务.png")
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
......@@ -2,37 +2,12 @@
1.创建一个基于原生SpringBoot框架的空应用
> :fa-hand-o-right: 这是在需要开发标准原生SpringBoot应用的特殊场景下的开发模式,依赖的`pangu-framework-parent`只提供了一点必要的非侵入依赖管理。
### 介绍
#### :four_leaf_clover: 如何创建&启动一个原生SpringBoot应用
- **第一步:安装pom依赖**
``` xml
<parent>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-parent</artifactId>
<version>latest.version.xxx</version>
<relativePath/>
</parent>
```
- **第二步:启动类**
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
采用SpringBoot标准启动方式启动。
### 更多资源
``` java
@SpringBootApplication
public class EmptySpringBootApplication {
public static void main(String[] args) {
SpringApplication.run(EmptySpringBootApplication.class, args);
}
@Component
public class EmptyService{
@PostConstruct
public void print(){
log.info("这是一个完全基于SpringBoot原生框架的空项目...");
}
}
}
```
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
......@@ -2,5 +2,12 @@
1. 创建一个基于盘古框架的Web空应用
> 特别提示:更多细节请查看范例代码和盘古开发文档。
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
......@@ -2,38 +2,12 @@
1. 创建一个基于盘古框架的空应用
#### :four_leaf_clover: 如何创建&启动一个盘古应用
- **第一步:安装pom依赖**
``` xml
<parent>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-parent</artifactId>
<version>latest.version.xxx</version>
<relativePath/>
</parent>
```
```xml
<dependency>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-spring-boot-starter</artifactId>
</dependency>
```
- **第二步:启动类**
采用SpringBoot标准启动方式启动。
``` java
@SpringBootApplication
public class EmptyPanguApplication {
public static void main(String[] args) {
PanGuApplicationBuilder.init(EmptyPanguApplication.class).run(args);
}
@Component
public class EmptyService{
@PostConstruct
public void print(){
log.info("这是一个基于盘古开发框架的空应用...");
}
}
}
```
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
\ No newline at end of file
......@@ -2,4 +2,12 @@
1. 如何使用基于Redis的分布式锁(注解式、API式)。
**更多开发指南请参考盘古平台相关文档说明。**
\ No newline at end of file
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
\ No newline at end of file
#### :mushroom: 范例演示功能
1. 如何在线热切换日志输出级别。
> :fa-thumbs-o-up: 通过在Nacos配置中心修改日志级别配置参数,应用监听日志级别参数变更并动态刷新日志级别。
### 介绍
#### :four_leaf_clover: 如何在线热切换日志级别
- **第一步:安装pom依赖**
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
```xml
<parent>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-parent</artifactId>
<version>latest.version.xxx</version>
<relativePath/>
</parent>
```
```xml
<dependency>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-spring-boot-starter</artifactId>
</dependency>
```
### 更多资源
- **第二步:模块的本地配置文件模版**
```properties
spring.application.name=pangu-examples-log-dynamic
spring.profiles.active=${spring.profiles.active:dev}
nacos.config.bootstrap.enable=true
nacos.config.bootstrap.log-enable=true
nacos.config.auto-refresh=true
#对应Nacos配置中心的命名空间ID
nacos.config.namespace=${nacos.namespace:pangu-dev}
nacos.config.server-addr=${nacos.server-addr:127.0.0.1:8848}
nacos.config.type=properties
nacos.config.data-id=${spring.application.name}.properties
```
- **第三步:在Nacos配置中心新建配置**
在配置中心命名空间(`nacos.config.namespace`值)下,新建DataId为`pangu-examples-log-dynamic.properties`的配置文件。
```properties
# 演示如何在线热切换日志级别
logging.level.root=INFO
logging.level.com.gitee.pulanos.pangu=INFO
logging.level.com.alibaba.nacos.client.config.impl.ClientWorker=WARN
```
- **第四步:启动&验证效果**
> 请在Nacos控制台修改日志级别后查看输出效果。
``` java
@SpringBootApplication
public class DynamicLogApplication {
public static void main(String[] args) {
PanGuApplicationBuilder.init(DynamicLogApplication.class).run(args);
}
@Component
public class DynamicLogExample {
@PostConstruct
public void execute() {
CronUtil.schedule("*/10 * * * * *", new Task() {
@Override
public void execute() {
Console.log("演示日志级别热切换功能,请在Nacos控制台修改日志级别后查看输出效果");
log.trace("这是trace信息");
log.debug("这是debug信息");
log.info("这是info信息");
log.warn("这是warn信息");
log.error("这是error信息");
}
});
CronUtil.setMatchSecond(true);
CronUtil.start();
}
}
}
```
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
......@@ -2,4 +2,12 @@
1. 如何编写WebAPI接口,基于远程Dubbo服务调用的微服务开发模式。
> 特别提示:更多细节请查看范例代码和盘古开发文档。
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
......@@ -2,10 +2,12 @@
1. 如何编写WebAPI接口,基于ShenYu网关实现泛华调用后端Dubbo服务。
> 盘古网关基于Apache Shenyu 网关系统开发。
> - 支持各种语言(http 协议),支持 Dubbo、 Spring Cloud、 gRPC、 Motan、 Sofa、 Tars 等协议。
> - 灵活的流量筛选,能满足各种流量控制。流量配置动态化,性能极高。
> - 内置丰富的插件支持,鉴权,限流,熔断,防火墙等等。
> - 支持集群部署,支持 A/B Test,蓝绿发布。
### 介绍
**更多开发指南请参考盘古平台相关文档说明。**
\ No newline at end of file
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
\ No newline at end of file
......@@ -2,4 +2,12 @@
1. 如何编写WebAPI接口,基于本地服务调用的传统单体开发模式。
> 特别提示:更多细节请查看范例代码和盘古开发文档。
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
pangu-gateway-spring-boot-starter
\ No newline at end of file
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
\ No newline at end of file
#### :mushroom: 代码生成器介绍
### 介绍
盘古代码生成器以Maven插件的方式提供,可以方便的辅助生成符合盘古应用开发规范的模版代码。目前版本支持生成实体类、MyBatis(Plus) Mapper接口。
#### :four_leaf_clover: 安装&配置
```xml
<plugin>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-framework-generator-maven-plugin</artifactId>
<version>5.0.6</version>
<configuration>
<url>jdbc:mysql://127.0.0.1:3306/pangu-examples</url>
<user>root</user>
<password>root123456</password>
<tables>user</tables>
<author>普蓝开源社区</author>
<!-- 可以使用绝对路径 -->
<entityFilePath>${project.basedir}/src/main/java/com/gitee/pulanos/pangu/showcases/crud/dao/entity</entityFilePath>
<entityPackageName>com.gitee.pulanos.pangu.showcases.crud.dao.entity</entityPackageName>
<mapperFilePath>${project.basedir}/src/main/java/com/gitee/pulanos/pangu/showcases/crud/dao/mapper</mapperFilePath>
<mapperPackageName>com.gitee.pulanos.pangu.showcases.crud.dao.mapper</mapperPackageName>
</configuration>
</plugin>
```
#### :tw-2708: 执行插件
执行maven脚本:`mvn pangu:generate`。输出如下所示信息。
```log
xc@xc-mac pangu-examples-crud % mvn pangu:generate
[INFO] Scanning for projects...
[INFO]
[INFO] ------------< com.gitee.pulanos.pangu:pangu-examples-crud >-------------
[INFO] Building pangu-examples-crud 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- pangu-framework-generator-maven-plugin:5.0.6:generate (default-cli) @ pangu-examples-crud ---
[INFO] 开始生成数据表[user]对应的实体对象...
[INFO] UserEntity.java 生成成功。文件路径:/Users/xc/git2/pangu-framework/pangu-examples/pangu-examples-crud/src/main/java/com/gitee/pulanos/pangu/showcases/crud/dao/entiity.java
[INFO] 开始生成数据表[user]对应的数据访问接口...
[INFO] UserMapper.java 生成成功。文件路径:/Users/xc/git2/pangu-framework/pangu-examples/pangu-examples-crud/src/main/java/com/gitee/pulanos/pangu/showcases/crud/dao/mapper/UserMapper.java
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.291 s
[INFO] Finished at: 2021-11-15T21:54:22+08:00
[INFO] ------------------------------------------------------------------------
```
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
\ No newline at end of file
pangu-jdbc-spring-boot-starter
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
pangu-spring-boot-starter
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
pangu-web-spring-boot-starter
\ No newline at end of file
### 介绍
[盘古开发框架](https://pulanos.gitee.io/pangu-framework/)是一套轻量灵活的Java开源企业级单体开发 & 微服务分布式开发治理框架。
### 更多资源
- :fa-book: [项目主页&开发指南](https://pulanos.gitee.io/pangu-framework/)
- :fa-flask: [开发范例集合](https://pulanos.gitee.io/pangu-framework/docs/examples-list)
- :fa-linux: [普蓝开源社区](https://pulanos.gitee.io/pangu-framework/docs/community/)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册