SpringBoot+Maven项目的配置构建



在这里插入图片描述


1、application.properties

也可使用yml yaml

#静态资源
spring.mvc.static-path-pattern=/images/**
#上传文件大小设置
spring.http.multipart.max-file-size=10MB
spring.http.multipart.max-request-size=10MB

spring.mvc.pathmatch.matching-strategy=ant_path_matcher

spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/数据库名字
spring.datasource.username=root
spring.datasource.password=root
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl

2、pom.xml

主要部分配置

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

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

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>


        <!-- MySQL -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.47</version>
            <scope>runtime</scope>
        </dependency>
<!--       数据库连接池  druid  -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.2.20</version>
        </dependency>
<!--        mybatisplus -->

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


<!-- Swagger -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>

    </dependencies>
  • 6
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Spring Boot是一款非常流行的Java Web框架,而多模块项目构建则是在实际开发中非常常见的需求。Maven是Java应用的依赖管理工具,结合Spring Boot可以很方便地构建、运行和打包多模块项目。 首先,需要创建一个父模块,它将在编译和打包时引用所有子模块。在父模块的pom.xml文件中,需要指定每个子模块的groupId、artifactId和version等信息。 接下来,我们可以创建子模块,每个子模块都可以包含一个或多个Spring Boot应用程序。在子模块的pom.xml文件中,需要指定它们的父模块坐标,以及它们自身的坐标。 在Java代码中,我们只需要使用@SpringBootApplication注解启动Spring Boot应用程序,以便使用Spring Boot的自动配置和构件功能。同时,我们也可以使用@SpringBootApplication注解打包可执行jar文件,另外需要使用Maven插件将其构建为可执行jar包,这样我们就可以使用"java -jar"命令行运行应用程序。 最后,我们需要为所有子模块构建和打包项目。在Maven的父模块pom.xml文件中,执行"mvn clean install"命令即可完成所有子模块和父模块的构建和打包工作。 总结来说,Spring BootMaven的多模块构建、运行和打包实战需要以下步骤:创建父模块和子模块,使用@SpringBootApplication注解启动应用程序,使用Maven插件构建jar包,最后执行"mvn clean install"命令完成构建和打包。这个过程需要多次尝试和调整,但可以大大提高开发效率和项目的可维护性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值