jhipster无法将弹簧运行配置文件更改为产品-始终以dev,swagger-Maven即服务开头

问题描述 投票:0回答:1

我在做

编辑

我正在使用jhipster框架https://www.jhipster.tech/production/

java -jar n1.jar

[请注意,此JAR文件使用我们在构建文件时选择的配置文件。由于它是使用上一节中的prod文件构建的,因此它将与prod配置文件一起运行。

结束编辑

./mvnw -Pprod clean verify

并且以dev开头,没有产品概要。

我是否需要更改pom文件中的某些内容?

        <id>prod</id>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-undertow</artifactId>
                <scope>provided</scope>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <configuration>
                        <filesets>
                            <fileset>
                                <directory>target/classes/static/</directory>
                            </fileset>
                        </filesets>
                    </configuration>
                </plugin>

要在Debian服务器中设置为服务,我要做:

sudo chmod +x /var/lib/nms-api/n2.jar
sudo chown nmsapi:nmsapi /var/lib/nms-api/n1.jar
sudo ln -s /var/lib/nms-api/n2.jar /etc/init.d/nms2
sudo systemctl enable nms2
sudo service nms2 start

和ps -aux说:

/ usr / bin / java -Dsun.misc.URLClassPath.disableJarChecking = true -jar /var/lib/nms-api/n1.jar

是否有设置方法

spring-boot maven jhipster pom.xml profile
1个回答
1
投票

您正在混淆Maven配置文件和Spring Boot配置文件。它们是两个完全独立的概念。 Maven概要文件是用于在构建期间打开特定步骤的标志,而spring概要文件是一个运行时标志,用于告诉spring应用哪个配置集。有关弹簧轮廓的更多信息,您可以see here

Spring概要文件可以通过systen属性,环境变量进行设置,也可以通过您的Maven构建进行设置。前两个是更灵活的imo。

系统属性

java -Dspring.profiles.active=prod

环境变量

export SPRING_PROFILES_ACTIVE=prod

作为Maven构建配置文件的一部分

 <profiles>
    <profile>
        <id>prod</id>
        <properties>
            <spring.profiles.active>prod</spring.profiles.active>
        </properties>
        <!-- The rest of your profile here -->
    </profile>
  </profiles>
© www.soinside.com 2019 - 2024. All rights reserved.