首页 > 其他分享 >idea新建一个多模块的springCloud项目

idea新建一个多模块的springCloud项目

时间:2023-11-22 17:32:23浏览次数:29  
标签:-- springCloud idea springframework commons version 模块 org com

新建一个多模块的springCloud项目

1.新建主项目woniuCRM

idea新建一个多模块的springCloud项目_ci

idea新建一个多模块的springCloud项目_ci_02

新建完后修改pom文件,且增加合适的依赖

idea新建一个多模块的springCloud项目_java_03

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <modules>
        <module>service</module>
    </modules>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <groupId>com.woniu</groupId>
    <artifactId>woniucrm</artifactId>
    <packaging>pom</packaging>
    <version>1.0.0</version>
    <name>woniuCRM</name>
    <url>http://www.woniucrm.com</url>
    <description>蜗牛CRM管理系统</description>


    <properties>
        <woniu.version>1.0.0</woniu.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <mybatis-plus.version>3.0.5</mybatis-plus.version>
        <velocity.version>2.0</velocity.version>
        <swagger.version>2.7.0</swagger.version>
        <aliyun.oss.version>2.8.3</aliyun.oss.version>
        <jodatime.version>2.10.1</jodatime.version>
        <poi.version>3.17</poi.version>
        <commons-fileupload.version>1.3.1</commons-fileupload.version>
        <commons-io.version>2.6</commons-io.version>
        <httpclient.version>4.5.1</httpclient.version>
        <jwt.version>0.7.0</jwt.version>
        <aliyun-java-sdk-core.version>4.3.3</aliyun-java-sdk-core.version>
        <aliyun-sdk-oss.version>3.1.0</aliyun-sdk-oss.version>
        <aliyun-java-sdk-vod.version>2.15.2</aliyun-java-sdk-vod.version>
        <aliyun-java-vod-upload.version>1.4.11</aliyun-java-vod-upload.version>
        <aliyun-sdk-vod-upload.version>1.4.11</aliyun-sdk-vod-upload.version>
        <fastjson.version>1.2.28</fastjson.version>
        <gson.version>2.8.2</gson.version>
        <json.version>20170516</json.version>
        <commons-dbutils.version>1.7</commons-dbutils.version>
        <canal.client.version>1.1.0</canal.client.version>
        <docker.image.prefix>zx</docker.image.prefix>
        <cloud-alibaba.version>0.2.2.RELEASE</cloud-alibaba.version>

    </properties>


    <!-- 依赖声明 -->
    <dependencyManagement>
        <dependencies>
            <!--Spring Cloud-->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Hoxton.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${cloud-alibaba.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!--mybatis-plus 持久层-->
            <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus-boot-starter</artifactId>
                <version>${mybatis-plus.version}</version>
            </dependency>

            <!-- velocity 模板引擎, Mybatis Plus 代码生成器需要 -->
            <dependency>
                <groupId>org.apache.velocity</groupId>
                <artifactId>velocity-engine-core</artifactId>
                <version>${velocity.version}</version>
            </dependency>

            <!--swagger-->
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
                <version>${swagger.version}</version>
            </dependency>
            <!--swagger ui-->
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger-ui</artifactId>
                <version>${swagger.version}</version>
            </dependency>

            <!--日期时间工具-->
            <dependency>
                <groupId>joda-time</groupId>
                <artifactId>joda-time</artifactId>
                <version>${jodatime.version}</version>
            </dependency>

            <!--xls-->
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
                <version>${poi.version}</version>
            </dependency>
            <!--xlsx-->
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi-ooxml</artifactId>
                <version>${poi.version}</version>
            </dependency>

            <!--文件上传-->
            <dependency>
                <groupId>commons-fileupload</groupId>
                <artifactId>commons-fileupload</artifactId>
                <version>${commons-fileupload.version}</version>
            </dependency>

            <!--commons-io-->
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>${commons-io.version}</version>
            </dependency>

            <!--httpclient-->
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>${httpclient.version}</version>
            </dependency>

            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>${gson.version}</version>
            </dependency>

            <!-- JWT -->
            <dependency>
                <groupId>io.jsonwebtoken</groupId>
                <artifactId>jjwt</artifactId>
                <version>${jwt.version}</version>
            </dependency>

            <!-- 工具类 -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>${fastjson.version}</version>
            </dependency>
            <dependency>
                <groupId>org.json</groupId>
                <artifactId>json</artifactId>
                <version>${json.version}</version>
            </dependency>

            <dependency>
                <groupId>commons-dbutils</groupId>
                <artifactId>commons-dbutils</artifactId>
                <version>${commons-dbutils.version}</version>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <repositories>
        <repository>
            <id>public</id>
            <name>aliyun nexus</name>
            <url>https://maven.aliyun.com/repository/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>public</id>
            <name>aliyun nexus</name>
            <url>https://maven.aliyun.com/repository/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

</project>

同理新建service模块,这是个业务模块

业务模块pom

idea新建一个多模块的springCloud项目_java_04

<?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/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>woniucrm</artifactId>
        <groupId>com.woniu</groupId>
        <version>1.0.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>service</artifactId>
    <packaging>pom</packaging>
    <modules>
        <module>woniu-user</module>
    </modules>

    <dependencies>


<!--        <dependency>-->
<!--            <groupId>org.springframework.cloud</groupId>-->
<!--            <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>-->
<!--        </dependency>-->

<!--        <!–hystrix依赖,主要是用  @HystrixCommand –>-->
<!--        <dependency>-->
<!--            <groupId>org.springframework.cloud</groupId>-->
<!--            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>-->
<!--        </dependency>-->

        <!--服务注册-->
<!--        <dependency>-->
<!--            <groupId>org.springframework.cloud</groupId>-->
<!--            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>-->
<!--        </dependency>-->
<!--        <!–服务调用–>-->
<!--        <dependency>-->
<!--            <groupId>org.springframework.cloud</groupId>-->
<!--            <artifactId>spring-cloud-starter-openfeign</artifactId>-->
<!--        </dependency>-->

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!--mybatis-plus-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
        </dependency>

        <!--mysql-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

        <!-- velocity 模板引擎, Mybatis Plus 代码生成器需要 -->
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity-engine-core</artifactId>
        </dependency>

        <!--swagger-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
        </dependency>

        <!--lombok用来简化实体类:需要安装lombok插件-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

        <!--xls-->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
        </dependency>

        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
        </dependency>

        <!--httpclient-->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </dependency>
        <!--commons-io-->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <!--gson-->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>
</project>

然后新建业务子模块 用户模块user

idea新建一个多模块的springCloud项目_ci_05

<?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/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>service</artifactId>
        <groupId>com.woniu</groupId>
        <version>1.0.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>woniu-user</artifactId>

    <dependencies>

        <!--httpclient-->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </dependency>
        <!--commons-io-->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <!--gson-->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>
    </dependencies>

</project>

yml文件

server:
  port: 8160
  servlet:
    context-path: /user
spring:
  application:
    name: woniu-user
#  cloud:
#    nacos:
#      discovery:
#        server-addr: 127.0.0.1:8848
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/woniucrm?serverTimezone=GMT%2B8
    username: root
    password: 
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss
    time-zone: GMT+8
#  redis:
#    database: 0
#    host: 127.0.0.1
#    lettuce:
#      pool:
#        max-active: 20
#        max-idle: 5
#        max-wait: -1
#        min-idle: 0
#    port: 6379
#    timeout: 1800000


mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  mapper-locations: classpath:com/woniu/woniuuser/mapper/xml/*.xml

启动类

package com.woniu.woniuuser;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
//import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
//@EnableDiscoveryClient
@ComponentScan(basePackages = {"com.woniu"})
@MapperScan("com.woniu.woniuuser.mapper")
public class UserApplication {

    public static void main(String[] args) {
        SpringApplication.run(UserApplication.class, args);
    }
}

UserController类

package com.woniu.woniuuser.controller;


import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author woniu
 * @since 2023-07-13
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {

    //登录
    @PostMapping("login")
    public String loginUser(@RequestParam String name) {
        log.info("name"+name);
        return "name";
    }

}

项目结构

idea新建一个多模块的springCloud项目_spring_06

idea新建一个多模块的springCloud项目_spring_07

标签:--,springCloud,idea,springframework,commons,version,模块,org,com
From: https://blog.51cto.com/u_16337916/8519037

相关文章

  • 每次打开IDEA都会indexing很耗时怎么办?
      每次打开IDEA都会indexing好半天,大一点的项目要几个小时,很是搞人心态。 解决办法:IntelliJIDEA->Preferences... 直接搜索index 然后旁边两个选项都选择Don’tdownload,uselocalindexes亲测有用!————————————————REFERENCEhttps://blog.csdn.n......
  • 【Spring】SpringCloudの環境構築(restTemplate+ribbon)
    参考URL:<https://zhuanlan.zhihu.com/p/272663162?utm_id=0>■紹介 SpringCloudの初心者に向け、簡単な手順を作成する。Eurekaサーバを利用して、「server」を立って。それにして、提供者(provider)と消費者(consumer)を全て「server」に導入して、管理する。消費者(consumer......
  • 【Spring】SpringCloudの環境構築
    ■説明SpringCloudの初心者に向け、詳しくの配置流れを紹介します。 ■ライブラリ・OracleのJDK:17・SpringCloud:2021.0.8・SpringBoot:2.7.17・MySql:8.0.33・Druid:1.2.20・MyBatis:2.3.1・LogbackCore:1.3.11・Lombok:1.18.22・Log4j:1.2.17・Junit:5.9.1・Gradle:8 ......
  • IDEA 自己常用快捷键
    Shift+Click,可以关闭文件Ctrl+[OR],可以跑到大括号的开头与结尾Ctrl+N,可以快速打开类Ctrl+Shift+N,可以快速打开文件Alt+Insert,可以生成构造器/Getter/Setter等Ctrl+Alt+L,格式化代码Ctrl+Enter,导入包,自动修正Ctrl+Alt+T,可以把代码包在一个块内,例如:try/catchCtrl+R......
  • git clone 时拉取子模块
    gitclone时拉取子模块 对还未下载的项目:gitclone--recursive对已下载的项目:gitsubmodulesyncgitsubmoduleupdate--init--recursive......
  • SpringCloud项目使用nacos配置
    SpringCloud项目pom.xml注意SpringCloud和SpringCloudAlibaba的版本对应。SpringCloudAlibabaVersionSpringCloudVersionSpringBootVersion2022.0.0.0*SpringCloud2022.0.03.0.22022.0.0.0-RC2SpringCloud2022.0.03.0.22022.0.0.0-RC1Spring......
  • idea报错Java HotSpot(TM) 64-Bit Server VM warning Options -Xverifynone and -nove
    问题描述我的:IDEA的版本为:2021.3‍最近在使用idea运行SpringBoot时,idea总是显示报错信息,报错信息如下:‍​​‍解决方法‍第一步:选择下图的EditConfigurations‍​​‍第二步:在跳转出的界面中找到Modifyoptions这个选项,点进去‍​​‍第......
  • 5.2 Windows驱动开发:内核取KERNEL模块基址
    模块是程序加载时被动态装载的,模块在装载后其存在于内存中同样存在一个内存基址,当我们需要操作这个模块时,通常第一步就是要得到该模块的内存基址,模块分为用户模块和内核模块,这里的用户模块指的是应用层进程运行后加载的模块,内核模块指的是内核中特定模块地址,本篇文章将实现一个获......
  • 5.3 Windows驱动开发:内核取应用层模块基址
    在上一篇文章《内核取ntoskrnl模块基地址》中我们通过调用内核API函数获取到了内核进程ntoskrnl.exe的基址,当在某些场景中,我们不仅需要得到内核的基地址,也需要得到特定进程内某个模块的基地址,显然上篇文章中的方法是做不到的,本篇文章将实现内核层读取32位应用层中特定进程模块基址......
  • ubuntu在睡眠恢复后自动加载gpu驱动模块的方法:
    我的ubuntu18,睡眠唤醒后,gpu通讯会出现问题。因此我写了一个脚本,唤醒后执行。就可以继续我的gpu实验了。如果nvidia_uvm被占用的话,还需要停止占用内核的jupyternotebook。重新加载cuda驱动(py37)dn@SSD-Panson:~$cat10_resume_from_sleep.sh#应对ubuntu睡眠唤醒后无法与gpu......