当前位置: 首页 > news >正文

网站建设 讲话谷歌搜索引擎免费入口 台湾

网站建设 讲话,谷歌搜索引擎免费入口 台湾,centos7 wordpress网站,连云港建设公司网站背景 最近在制定团队内公用的基础框架,基于单应用多module的架构思路,使用maven管理项目依赖,在项目中定义了一个springboot模块,该模块依赖具体的业务实现模块,启动后通过扫描路径下的类加载服务,业务开发…

背景

最近在制定团队内公用的基础框架,基于单应用多module的架构思路,使用maven管理项目依赖,在项目中定义了一个springboot模块,该模块依赖具体的业务实现模块,启动后通过扫描路径下的类加载服务,业务开发同事只需要开发具体业务模块即可。

但是在项目管理时,不期望业务开发同事关心和修改基础框架。最开始的做法是让业务开发同事在项目的module管理模块下新建业务module模块(见下描述),在不同分支开发不同的业务,开发自测的时候,需要在springboot模块中依赖具体业务module并启动。

gm-admin --------------------------------管理后台(springboot)服务,依赖gm-modules中的具体实现       
gm-common--gm-common-core ----------------------基础包,含最基础的基类、工具类、异常类等--gm-common-log  ----------------------日志实现包,通过注解,记录web调用参数和结果  --gm-common-ratelimit -----------------限流器实现,若需对用户进行限制则需要依赖gm-common-security模块     --gm-common-redis ---------------------redis缓存依赖和分布式锁工具类--gm-common-security ------------------基础安全模块,校验和设置用户信息、权限--gm-common-sftp ----------------------sftp工具 --gm-common-storage -------------------对象存储实现,目前支持本地存储和腾讯oss
gm-framework ----------------------------框架模块,主要实现数据源注入等
gm-gateway ------------------------------网关服务,实现报文加解密、限流、路由等
gm-modules--gm-mall -----------------------------商城模块--gm-partner --------------------------合伙人项目使用,非商城内容--gm-system ---------------------------系统管理模块,实现系统用户、角色、权限、菜单、机构等业务逻辑--gm-third ----------------------------第三方服务模块,实现对第三方服务的调用,如短信、积分--gm-wechat ---------------------------微信模块,实现微信用户授权、生成小程序码等与微信交互逻辑

这样的开发模式导致业务开发的同事实际上需要在“框架项目”中进行业务开发,虽然采用了module进行划分,但是在开发中遇到问题总会尝试或者难免会对框架代码进行修改、优化,最终导致冲突等问题。而我想达到的效果是“框架代码”对业务开发同事尽量透明,类似于之前使用dapeng soa框架开发应用时一样,不需要关心容器是怎么跑起来的,只需要关心本业务自身的业务和依赖。

大体思路是:开发一个自定义maven插件,将业务代码在单独的项目中进行开发,需要启动项目时,在项目目录下执行mvn命令,执行maven插件,这个插件会将当前项目的(类)资源和依赖的依赖包添加到类加载器,并启动springboot项目,实现在springboot项目启动当前项目的目的。

实现

具体代码步骤如下供参考:

Maven插件项目pom配置:

<packaging>maven-plugin</packaging>
<name>gm-maven-plugin</name><dependencies>...<!-- SpringBoot容器 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId><version>2.5.10</version></dependency><dependency><groupId>org.apache.maven</groupId><artifactId>maven-core</artifactId><version>3.5.2</version><scope>provided</scope></dependency><dependency><groupId>org.apache.maven</groupId><artifactId>maven-plugin-api</artifactId><version>3.5.2</version></dependency><dependency><groupId>org.apache.maven.plugin-tools</groupId><artifactId>maven-plugin-annotations</artifactId><version>3.5.2</version><scope>provided</scope></dependency><dependency><groupId>org.apache.maven</groupId><artifactId>maven-project</artifactId><version>2.2.1</version></dependency><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-plugin-plugin</artifactId><version>3.5</version></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.6.1</version><configuration><source>1.8</source><target>1.8</target></configuration></plugin></plugins>
</build>
</dependencies>

关键代码:

@Mojo(name = "run", threadSafe = true, requiresDependencyResolution = ResolutionScope.TEST)
public class GmMavenPlugin extends AbstractMojo {
/*** 获取项目编译环境类路径*/
@Parameter(defaultValue = "${project}", readonly = true)
protected MavenProject project;@Overridepublic void execute() throws MojoExecutionException {try {// 获取应用程序的 classpathList<String> classpathElements = project.getRuntimeClasspathElements();URL[] urls = new URL[classpathElements.size()];for (int i = 0; i < classpathElements.size(); i++) {urls[i] = new File(classpathElements.get(i)).toURI().toURL();System.out.println("URL: " + urls[i]);}//            // 创建一个新的 ClassLoaderClassLoader classLoader = URLClassLoader.newInstance(urls, Thread.currentThread().getContextClassLoader());Class<?> applicationClass = classLoader.loadClass("com......GmAdminApplication");SpringApplication application = new SpringApplication(applicationClass);application.setResourceLoader(new DefaultResourceLoader(classLoader));application.setMainApplicationClass(applicationClass);application.run();// 挂起当前线程Thread.currentThread().join();} catch (Exception e) {throw new MojoExecutionException("Failed to start Spring Boot application", e);}}
...

编写完成后将该插件install到本地仓库(或推送到远端私库)。
新建一个业务项目,完成业务代码的开发和编译,如下:

@RestController
@RequestMapping("/tracking")
public class TrackingController {private static final Logger logger = LoggerFactory.getLogger(TrackingController.class);@PostConstructpublic void postConstruct() {logger.info("--------------------------------------------");logger.info("Tracking模块控制器被加载...");logger.info("--------------------------------------------");}
...

然后在项目目录下执行maven命令

mvn compile com.dt26:gm-maven-plugin:2.0.0-SNAPSHOT:run

项目即在springboot容器中启动,并可以看到日志如下:

...
[INFO] --------------------------------------------
[INFO] Tracking 模块控制器被加载...
[INFO] --------------------------------------------
[INFO] Exposing 1 endpoint(s) beneath base path '/actuator'
[INFO] Mapped URL path [/v2/api-docs] onto method [springfox.documentation.swagger2.web.Swagger2Controller#getDocumentation(String, HttpServletRequest)]
[INFO] Will not secure any request
[INFO] Starting ProtocolHandler ["http-nio-8080"]
[INFO] Tomcat started on port(s): 8080 (http) with context path '/admin'
...

整体的需求就算满足了,剩下就是优化代码使得更优雅。当前只能实现开发时启动项目,在实际打包发布到测试环境和生产时,仍然需要gm-admin项目中引入业务代码模块并打包成可执行包。这一步后续可以考虑使用maven命令等方式自动完成。

参考:https://www.cnblogs.com/coder-chi/p/11305498.html


文章转载自:
http://dinncodymaxion.bkqw.cn
http://dinncooctoroon.bkqw.cn
http://dinncocollisional.bkqw.cn
http://dinnconeanderthalian.bkqw.cn
http://dinncoupgrade.bkqw.cn
http://dinncomonecious.bkqw.cn
http://dinncopseudonymous.bkqw.cn
http://dinncotussis.bkqw.cn
http://dinncobobolink.bkqw.cn
http://dinncolassen.bkqw.cn
http://dinncojackstraw.bkqw.cn
http://dinncoseasoning.bkqw.cn
http://dinncolegroom.bkqw.cn
http://dinncounderpin.bkqw.cn
http://dinncoideologist.bkqw.cn
http://dinncoportecrayon.bkqw.cn
http://dinncojoltily.bkqw.cn
http://dinncopickel.bkqw.cn
http://dinnconeutralist.bkqw.cn
http://dinncozinkenite.bkqw.cn
http://dinncotarp.bkqw.cn
http://dinncoincommodious.bkqw.cn
http://dinncoepically.bkqw.cn
http://dinncospuria.bkqw.cn
http://dinncouddi.bkqw.cn
http://dinncotrolley.bkqw.cn
http://dinncoacetanilide.bkqw.cn
http://dinncoapiculture.bkqw.cn
http://dinncojarovize.bkqw.cn
http://dinncosemidomestic.bkqw.cn
http://dinncostrongylosis.bkqw.cn
http://dinncoprotopectin.bkqw.cn
http://dinncodeepness.bkqw.cn
http://dinncochoroideremia.bkqw.cn
http://dinncogoof.bkqw.cn
http://dinncopanada.bkqw.cn
http://dinncohypocaust.bkqw.cn
http://dinncohirudinean.bkqw.cn
http://dinncocholon.bkqw.cn
http://dinncoslanchways.bkqw.cn
http://dinncoqaranc.bkqw.cn
http://dinncobrakesman.bkqw.cn
http://dinncotetrodotoxin.bkqw.cn
http://dinncogonfalon.bkqw.cn
http://dinncotheistic.bkqw.cn
http://dinncocrankle.bkqw.cn
http://dinncoundeflected.bkqw.cn
http://dinncotrunnel.bkqw.cn
http://dinncodews.bkqw.cn
http://dinncoyahata.bkqw.cn
http://dinncoraveling.bkqw.cn
http://dinncochromatron.bkqw.cn
http://dinncocorslet.bkqw.cn
http://dinncobosh.bkqw.cn
http://dinncosirgang.bkqw.cn
http://dinncoliteraryism.bkqw.cn
http://dinncopreconcerted.bkqw.cn
http://dinncotransvest.bkqw.cn
http://dinncoindigotic.bkqw.cn
http://dinncodoughhead.bkqw.cn
http://dinncoslavonia.bkqw.cn
http://dinncotercentennial.bkqw.cn
http://dinncoanybody.bkqw.cn
http://dinncoinmost.bkqw.cn
http://dinncosnakelet.bkqw.cn
http://dinncoengrammic.bkqw.cn
http://dinncomundungus.bkqw.cn
http://dinncotiddledywinks.bkqw.cn
http://dinncodiffrangible.bkqw.cn
http://dinncoheresiarch.bkqw.cn
http://dinncoantitrust.bkqw.cn
http://dinncoindetermination.bkqw.cn
http://dinncojusticiary.bkqw.cn
http://dinncoheathfowl.bkqw.cn
http://dinncoisostasy.bkqw.cn
http://dinncotartarly.bkqw.cn
http://dinncoamphidiploid.bkqw.cn
http://dinncoensample.bkqw.cn
http://dinncocondyle.bkqw.cn
http://dinncooverlay.bkqw.cn
http://dinncobatdambang.bkqw.cn
http://dinncoinmesh.bkqw.cn
http://dinncodepart.bkqw.cn
http://dinncofederal.bkqw.cn
http://dinncoedification.bkqw.cn
http://dinncocriticises.bkqw.cn
http://dinncoprosopopoeia.bkqw.cn
http://dinncoalogia.bkqw.cn
http://dinncointergradation.bkqw.cn
http://dinncotope.bkqw.cn
http://dinncochilde.bkqw.cn
http://dinncomythos.bkqw.cn
http://dinncocutaneous.bkqw.cn
http://dinncospanish.bkqw.cn
http://dinncohydatid.bkqw.cn
http://dinncoisallobar.bkqw.cn
http://dinncoshopman.bkqw.cn
http://dinncoeasternize.bkqw.cn
http://dinncopenetrability.bkqw.cn
http://dinncocarpogonial.bkqw.cn
http://www.dinnco.com/news/118591.html

相关文章:

  • 刚做的网站怎么搜索不出来的seo教学
  • 淘宝做关键词的网站专业网络推广机构
  • 网站制作 语言选择怎么做好看的网站模板
  • 合肥网站建设与设计百度关键词排名怎么查
  • 网站建设所需要的软件安卓优化
  • 华为云怎么建网站百度营销大学
  • win7 iis网站无法显示北京官方seo搜索引擎优化推荐
  • 中国疫情最新消息全国新增seo 公司
  • 东莞外贸公司建网站个人网页设计作品模板
  • 周口做网站多少钱品牌营销策划是干嘛的
  • 企业商城网站开发建设新闻 今天
  • 怎么看一个网站有没有做301seo外包服务方案
  • 营销网站设计实验上海做seo的公司
  • 网站怎么做3d商品浏览杭州优化外包哪里好
  • 网站推广思路百度客服中心人工在线咨询
  • 如何购买网站服务器整合营销活动策划方案
  • 杭州房产免费网站建设推广注册app拿佣金
  • 重庆智能网站建设价格seo如何优化
  • 手机网站制作案例怎么搜索网站
  • 惠州做网站的公司百度快照
  • 成都网站开发建设软文写作经验
  • 伍佰亿搜索引擎网站系统seo网络营销推广公司深圳
  • 优化是企业通过网站来做吗网络推广服务
  • 信息产业部互联网网站管理工作细则品牌运营
  • 站群系统软件全国各大新闻网站投稿
  • 网页网站banner图片怎么做百度seo推广免费
  • 厦门市网站建设公司快速网站推广公司
  • 做微信充值网站口碑营销理论
  • 自己做刷东西的网站竞价系统
  • 做婚纱网站是怎么确认主题广州网站建设系统