power版本
4.3.9
powerjob-server/powerjob-server-starter添加pom.xml
<!-- https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-alibaba-nacos-discovery -->
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><version>2021.0.4.0</version>
</dependency><!-- https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-alibaba-nacos-config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2021.0.4.0</version>
</dependency><!-- 不引入这个,启动项目的时候,读取不到nacos的配置文件 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>3.0.1</version>
</dependency><!-- 版本不一致,额外引入-->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.27</version>
</dependency><dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>6.1.6</version>
</dependency><dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
<version>3.1.6</version>
</dependency><!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-context -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-context</artifactId>
<version>3.1.6</version>
</dependency>
power版本
4.0.2
powerjob-server/powerjob-server-starter添加pom.xml
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><version>2021.1</version></dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId><version>2021.1</version></dependency><!-- 不引入这个,启动项目的时候,读取不到nacos的配置文件 --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId><version>3.0.1</version></dependency><dependency><groupId>org.yaml</groupId><artifactId>snakeyaml</artifactId><version>1.27</version></dependency>
启动类添加注解
@EnableDiscoveryClient
添加bootstrap.yml
## 连接的地址.
nacoshosts: 172.1.11.11:8848
## 配置以及服务分组名称 , 区分各个环境 dev test prod
groupname: DEFAULT_GROUP
# nacos 命名空间
namespace: public
## Spring
spring:application:## 应用名称name: power-jobprofiles:## 日志环境配置,不建议修改为active: testcloud:nacos:discovery:namespace: ${namespace}## 服务注册地址server-addr: ${nacoshosts}## 所属组信息.group: ${groupname}username: nacospassword: 111111config:namespace: ${namespace}## 配置中心地址server-addr: ${nacoshosts}## 配置文件格式file-extension: yml## propertiesusername: nacospassword: 111111logging:level:com.alibaba.nacos.client.config: WARN
server:port: 7070
项目集成
项目主要引入下面的依赖,千万要注意自己项目的springboot版本要和这个starter的版本一致,不然无法注册为bean,而且这个starter的包是从人家项目打出来的,如果你的项目的仓库是分开的就必须手动移动进去
<dependency><groupId>tech.powerjob</groupId><artifactId>powerjob-worker-spring-boot-starter</artifactId><version>${powerjob.worker.starter.version}</version></dependency>