搭建SpringBoot多模块问题点

packaging

在这里插入图片描述

  • 配置<packaging>pom</packaging>的意思是使用maven分模块管理,都会有一个父级项目,pom文件一个重要的属性就是packaging(打包类型),一般来说所有的父级项目的packaging都为pompackaging默认类型jar类型,如果不做配置,maven会将该项目打成jar

properties

在这里插入图片描述

  • 指定jdk版本以及项目maven编码集

druid

在这里插入图片描述

  • 当application.yml文件中配置数据源有druid时没有引入druid依赖,配置是失效的。

会报错:Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.
在这里插入图片描述

driver-class-name

在这里插入图片描述

  • 驱动名字要对上 不然也是无法注入上数据源的

文件编码

在这里插入图片描述

jdk编译版本

在这里插入图片描述

打包

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </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>
  • 多模块打包只需要在需要启动类的项目下写上插件打包即可

自动注入

出现Consider defining a bean of type ‘xxx‘ in your configuration

由于RedisUtils放在了公共模块中,并且也使用了@Component注解,但是自动注入找不到。

  • 可在主启动类中使用注解将公共模块也扫描进去
    scanBasePackages写上基础包名
@SpringBootApplication(scanBasePackages = "")

使用@ComponentScan注解也是一样的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值