F1V3.0-21 微服务旧版本升级
来源:互联网 发布:mac绝对路径怎么写 编辑:程序博客网 时间:2024/05/18 09:14
由于我们微服务的诸多好处,很多基于F12.0的项目必将大量迁移,整改成微服务项目,我们该如何进行升级呢?本文将做一个特殊说明,让你在迁移项目时少走弯路。
1 新建maven项目
命名为f1-xxxxx(推荐)
1.1 编写pom文件
本文提供一个通用模板如下所示:
<?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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>f1-xxxx</artifactId> <parent> <artifactId>f1-parent</artifactId> <groupId>com.joinbright.f1</groupId> <version>3.0.0-SNAPSHOT</version> </parent> <dependencies> <!-- 开发时热加载工具 --> <!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency> <groupId>com.joinbright.f1</groupId> <artifactId>f1-starter</artifactId> </dependency> <!--类型挂接脚本,访问model中的服务引入这个--> <dependency> <groupId>com.joinbright.f1</groupId> <artifactId>f1-interface-model</artifactId> </dependency> <dependency> <groupId>com.joinbright.f1</groupId> <artifactId>f1-starter-listener</artifactId> </dependency> <!--接入平台取得授权引入这个--> <dependency> <groupId>com.joinbright.f1</groupId> <artifactId>f1-starter-auth</artifactId> </dependency> <!--需要访问permission中的服务引入这个--> <dependency> <groupId>com.joinbright.f1</groupId> <artifactId>f1-interface-permission</artifactId> </dependency> <!--缓存引入这个--> <dependency> <groupId>com.joinbright.f1</groupId> <artifactId>f1-starter-cache</artifactId> </dependency> <!-- <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-sleuth-zipkin</artifactId> </dependency> --> <dependency> <groupId>net.logstash.logback</groupId> <artifactId>logstash-logback-encoder</artifactId> </dependency> </dependencies> <build> <finalName>f1-xxxx</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build></project>
1.2 编写启动类
创建一个根包 com.jb.xxxx(推介命名) ,在这个下面新建一个启动类。本文提供一个通用启动类:
@SpringBootApplication@EnableDiscoveryClient @EnableOAuth2Sso@EnableFeignClients("com.jb.*.client")@ComponentScan(basePackages ={"com.jb.xxx"})@EntityScan(basePackages = {"com.jb.*.model"})@EnableCachingpublic class XXXXXX{ @Bean @LoadBalanced RestTemplate restTemplate() { return new RestTemplate(); } @Bean public Logger.Level feignLoggerLevel() { return feign.Logger.Level.FULL; } public static void main(String[] args) { SpringApplication.run(XXXXXX.class,args); }}
1.3 建立配置文件
在 src/main/resources 下建立如下文件,这里配置文件内容不做过多说明,大家可以在平台提供的微服务中找到这些配置,稍作修改即可。
application.properties,bootstrap.properties,logback-spring.xml
同时把resource.xml拷贝到 src/main/resources 下
2 移植文件
对于后台文件的移植可能很简单,只要你引入正确的平台jar包,对于报错信息,更多的是jar包结构改变引起,我们只需要删除原来import的引入,eclipse会帮助我们自动检索,只需要点下鼠标即可成功引入。
2.1 service服务的移植
以前的osgi项目我们使用的是切面的形式在service层切入事物,现在我们使用注解的形式切入事物。
@Transactional(value="transactionManager",propagation=Propagation.REQUIRED)
2.2 control的移植
基本平滑移植。
2.3 Model的移植
对于@JsonProperty(“xxxx”)注解的属性需要
原来的为
import org.codehaus.jackson.annotate.JsonProperty
改变成:
import com.fasterxml.jackson.annotation.JsonProperty;
对于以前java文件,我们新版的F13.0对一些基础类的包结构可能做了更改,现在总结如下:
3 脚本的移植
平台不支持模型工具中直接编写脚本的方式,所以对于旧平台中模型工具中写的脚本需要移植到现在的服务中。
3.1 类型脚本移植
引入依赖 f1-interface-model
模型类型中的脚本改为如下模式:
第一步:
新建一个类继承自BaseClsScript,如下所示;
@Service("xxxxxx")@Transactional(value="transactionManager",propagation=Propagation.REQUIRED)public class SysConfigScript extends BaseClsScript{}
第二步:
找到对应的脚本:在模型工具中右键打开或者直接在 us_sys.tb_model_clsscript表中把脚本内容拷贝出来,粘贴到新建好的类中
第三步:
挂接脚本,在对应的类型鼠标右键选择挂接脚本,把服务ID,服务名称填上即可。
3.2 调度任务的脚本
引入依赖 f1-interface-quartz。
对于调度任务挂接脚本,只是实现的类不同,其他步骤基本一样。
第一步:新建一个类实现 IJobScript,如下所示;
@Service("quartScript")@Transactional(value="transactionManager",propagation=Propagation.REQUIRED)public class QuartScript implements IJobScript{ @Override public void execute(F1JobExecutionContext arg0) { System.out.println("调度任务脚本执行"); }}
第二步:
找到对应的脚本:在模型工具中右键打开或者直接在 us_sys.tb_model_clsscript表中把脚本内容拷贝出来,粘贴到新建好的类中
第三步:
挂接脚本,在对应的任务鼠标右键选择挂接脚本,把服务ID,服务名称填上即可。
第四步:
对于调度任务我们需要配置白名单
security.ignored=/jobScript/execute.do
3.3 工作流脚本
引入f1-interface-workflow。除了实现的接口不同,其他都和模型,调度任务挂接脚本一样。
流程环节实现:ProcessNodeUniteListener
流程迁移线实现:TransitionFilter
4 自己依赖jar包的升级
对于一些模块我们可能有自己引入的第三方jar包,可能和平台版本不兼容,这里建议对于以前旧的第三方包替换成支持jdk1.8的包。
5 移植前后项目对比
对于基于osgi的项目移植成微服务后项目结构要简单的多,没有那么多配置文件。
移植前项目结构
移植后的项目结构
- F1V3.0-21 微服务旧版本升级
- F1V3.0-22 前端旧版本升级方式
- F1V3.0-9 微服务功能介绍
- F1V3.0-12 微服务开发规范
- F1V3.0-14 微服务开发环境
- F1V3.0-5 平台3.0微服务架构设计
- F1V3.0-16 快速开发一个微服务
- F1V3.0-23 微服务打包发布部署
- F1V3.0-17 微服务常用功能开发
- F1V3.0-图形-微服务模块打包部署
- linux 升级旧版本jdk
- nginx旧版本升级新版本
- MySQL旧版本升级为新版本
- MajorUpgrade升级不能卸载旧版本
- Visual Studio手动升级旧版本程序
- 旧版本linux内核升级到新版本内核编译选择
- 升级archlinux旧版本pacman支持xz格式软件包
- ActiveReports 6:如何升级旧版本的项目
- simpletest for phpsa
- C语言实现视频异或加/解密
- 通过Canvas及File API缩放并上传图片完整示例
- Viewpager和Fragment
- busybox中memdev的使用方法
- F1V3.0-21 微服务旧版本升级
- Virtualbox 启用USB 设备支持
- HDU --- 5015 233 Matrix 【思维 + 矩阵快速幂】
- 如何做618数据复盘?你需要掌握这8大思路
- DM368开发 --IPNC 设置过程
- JavaConfig配置文件为Spring创建bean
- 窗体部件效果之窗体置顶
- LayoutInflater的使用
- 使用AS开发/调试整个android系统源代码