程序员王小瑞 2023-04-10 15:05 采纳率: 19.2%
浏览 56

ruoyiCloud部署问题

我在ruoyiCloud项目中使用动态切换环境进行配置,通过选择spring.profile标签进行动态切换
其中对项目中的yml也进行了配置,通过@spring.profile@,@nacos.server.address@,@nacos.server.namespace@,进行了动态配置
nacos也配置了相应的prod,其中的连接ip全部换成了容器名,ruoyi-mysql ruoyi-redis
当使用mvn clean package -P prod指定打包时服务报错:

img


nacos参考如下:

img

pom参考如下:

<profiles>
        <profile>
            
            <id>dev</id>
            <properties>
                <spring.profile>dev</spring.profile>
                <nacos.server.address>http://192.168.17.131:8848</nacos.server.address>
                <nacos.server.namespace></nacos.server.namespace>
            </properties>
            <activation>
                
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            
            <id>test</id>
            <properties>
                <spring.profile>test</spring.profile>
                <nacos.server.address>http://192.168.17.131:8848</nacos.server.address>
                <nacos.server.namespace>test</nacos.server.namespace>
            </properties>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
        </profile>
        <profile>
            
            <id>prod</id>
            <properties>
                <spring.profile>prod</spring.profile>
                <nacos.server.address>http://192.168.17.131:8848</nacos.server.address>
                <nacos.server.namespace>prod</nacos.server.namespace>
            </properties>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
        </profile>
    </profiles>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring-boot.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>


yml参考如下:

img

  • 写回答

3条回答 默认 最新

  • 心寒丶 全栈领域优质创作者 2023-04-10 15:19
    关注

    连接出现问题,项目注册naocs地址应调整为[容器名:9848] ruoyi-nacos:9848试试看

    img

    评论

报告相同问题?

问题事件

  • 创建了问题 4月10日

悬赏问题

  • ¥30 不会,学习,有偿解答
  • ¥15 SQL查询语句报错(检查)
  • ¥15 此表中公式应该怎么写
  • ¥15 求HI-TECH PICC 9.50 PL3安装包
  • ¥15 下载ctorch报错,求解
  • ¥15 如何入门学习c语言,单片机
  • ¥15 idea 编辑语言的选择
  • ¥15 Windows下部署Asmjit
  • ¥15 请问双层规划模型的上下层目标函数不一致,是如何保证迭代收敛性的
  • ¥30 微信小程序 前端页面内容搜索