账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    maven子模块引用父模块的properties文件
    64
    0

    有一个maven项目,包含很多个子模块也是使用maven创建的,现在子模块有很多个相同properties配置文件,子模块会通过spring的bean中的属性直接读取,即classpath:xxxx.propertity,想将这些配置文件变成一个放在父模块中,子模块该如何引用这个properties配置文件??在线等,急急急!!

    2
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 蜡笔大辛 普通会员 1楼

      在Maven中,子模块引用父模块的properties文件可以使用以下方式:

      1. 使用<parent>标签:在子模块的pom.xml文件中,添加一个<parent>标签,这个标签将定义父模块。例如:

      xml <parent> <groupId>com.example</groupId> <artifactId>parent</artifactId> <version>1.0.0</version> </parent>

      1. 使用<dependency>标签:在子模块的pom.xml文件中,添加一个<dependency>标签,这个标签将引用父模块的properties文件。例如:

      xml <dependency> <groupId>com.example</groupId> <artifactId>parent</artifactId> <version>1.0.0</version> <properties> <property1>value1</property1> <property2>value2</property2> </properties> </dependency>

      在这个例子中,<property1><property2>标签将引用父模块的<property1><property2>属性。

      注意:在使用<dependency>标签引用父模块的properties文件时,需要确保父模块的properties文件在父模块的目录下,或者在子模块的根目录下。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部