从零开始搭建微服务:通用模块搭建

通用模块主要用于定义一些各个微服务通用的实体类,工具类或者第三方依赖等。

新建通用模块

新建 Maven Module

File==>新建==>Other==>搜索Maven,选择Maven Module,然后Next
从零开始搭建微服务:通用模块搭建_第1张图片

填写Module Name

填写Module Name:elsa-common,点击Next
从零开始搭建微服务:通用模块搭建_第2张图片
一直Next至FInish为止,创建完成,项目结构如下
从零开始搭建微服务:通用模块搭建_第3张图片

父级Elsa-Cloud pom.xml

因为我们刚刚在创建elsa-common模块的时候选择elsa-cloud作为父模块,父级elsa-cloud pom.xml会自动添加如下内容。

	<modules>
		<module>elsa-commonmodule>
  	modules>

elsa-common pom配置

我们在elsa-common模块的pom里添加一些后续可能会用到的依赖。


<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">
    <parent>
        <artifactId>elsa-cloudartifactId>
        <groupId>com.elsagroupId>
        <version>1.0-SNAPSHOTversion>
    parent>
    <modelVersion>4.0.0modelVersion>

    <artifactId>elsa-commonartifactId>
    <name>Elsa-Commonname>
    <description>Elsa-Common通用模块description>

    <dependencies>
        <dependency>
            <groupId>com.alibabagroupId>
            <artifactId>fastjsonartifactId>
            <version>1.2.51version>
        dependency>
        <dependency>
            <groupId>org.apache.commonsgroupId>
            <artifactId>commons-lang3artifactId>
        dependency>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
        dependency>
        <dependency>
            <groupId>org.springframework.cloudgroupId>
            <artifactId>spring-cloud-starter-oauth2artifactId>
        dependency>
        <dependency>
            <groupId>org.springframework.cloudgroupId>
            <artifactId>spring-cloud-starter-securityartifactId>
        dependency>
    dependencies>
project>

至此,通用模块也搭建完毕了,下篇文章我们将开始搭建微服务注册中心。

源码下载

源码地址:通用模块源码

你可能感兴趣的:(从零开始搭建微服务,微服务,spring,cloud)