spring cloud项目父级pom里有<profiles>标签, 子模块pom里的<profiles>的问题

比如说父级的<profiles>标签配置了dev, test, prod三个环境, 默认使用dev

<profiles>
        <profile>
            <id>dev</id>
            <properties>
                <profileActive>dev</profileActive>
                <docker.registry.name>xxx</docker.registry.name>
                <docker.host>https://xxx:123</docker.host>
                <docker.pem></docker.pem>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>test</id>
            <properties>
                <profileActive>test</profileActive>
           <docker.registry.name>xxx</docker.registry.name>
                <docker.host>https://xxx:123</docker.host>
                <docker.pem></docker.pem>
            </properties>
        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <profileActive>prod</profileActive>
                <docker.registry.name>xxx</docker.registry.name>
                <docker.host>https://xxx:123</docker.host>
                <docker.pem></docker.pem>
            </properties>
        </profile>
    </profiles>

然后在子模块的<profiles>标签配置了dev, test, prod, adev, btest, cprod六个环境, 默认也是使用dev

<profiles>
        <profile>
            <id>dev</id>
            <properties>
                <profileActive>dev</profileActive>
                <docker.registry.name>xxx</docker.registry.name>
                <docker.host>https://xxx:123</docker.host>
                <docker.pem></docker.pem>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>test</id>
            <properties>
                <profileActive>test</profileActive>
           <docker.registry.name>xxx</docker.registry.name>
                <docker.host>https://xxx:123</docker.host>
                <docker.pem></docker.pem>
            </properties>
        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <profileActive>prod</profileActive>
                <docker.registry.name>xxx</docker.registry.name>
                <docker.host>https://xxx:123</docker.host>
                <docker.pem></docker.pem>
            </properties>
        </profile>
        <profile>
            <id>adev</id>
            <properties>
                <profileActive>adev</profileActive>
                <docker.registry.name>xxx</docker.registry.name>
                <docker.host>https://xxx:123</docker.host>
                <docker.pem></docker.pem>
            </properties>
        </profile>
        <profile>
            <id>btest</id>
            <properties>
                <profileActive>btest</profileActive>
                <docker.registry.name>xxx</docker.registry.name>
                <docker.host>https://xxx:123</docker.host>
                <docker.pem></docker.pem>
            </properties>
        </profile>
        <profile>
            <id>cprod</id>
            <properties>
                <profileActive>cprod</profileActive>
                <docker.registry.name>xxx</docker.registry.name>
                <docker.host>https://xxx:123</docker.host>
                <docker.pem></docker.pem>
            </properties>
        </profile>
    </profiles>

bootstrap.yml中使用${@profileActive@:dev}的方式获取标签中配置的环境

spring:
  profiles:
    active: ${@profileActive@:dev}

启动项目的时候使用默认dev
image.png

但是编译之后的bootstrap.yml文件里竟然不是${dev:dev}这样的而是${@profileActive@:dev}, 相当于直接复制进来的

如果使用maven的compile就能正常编译了但是启动的时候还是会变成没有编译的样子
image.png

如果不在子模块添加<profiles>标签编译使用dev, test, prod环境就正常了, 有没有办法能让在子模块中添加<profiles>标签也能正常编译呢, 因为项目需求这个子模块必须得有跟别的模块不同的环境, 但又不能给父级pom里添加多余的环境, 这该怎么做呢

阅读 1.2k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题