Pourquoi mes variables d'environnement ne fonctionne pas au Printemps(maven)?

0

La question

Je travaille avec intellij, j'définir les variables d'environnement dans Maven de configuration (en haut à droite, ajouter la configuration, le coureur, les variables d'environnement)

C'est comme il lit le nom de la variable une Chaîne au lieu d'une variable aide s'il vous plaît

propriétés de l'application:

server.port=8081
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://${MYSQL_HOST}?zeroDateTimeBehavior=convertToNull
spring.datasource.username=${SERVICE_USER}
spring.datasource.password=${SERVICE_PASSWORD}
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.globally_quoted_identifiers=true
#spring.jpa.show-sql: true

les variables d'environnement(dans maven de configuration):

SERVICE_PASSWORD=;MYSQL_HOST=localhost:3306/orderup;SERVICE_USER=root

le message:

No such host is known (${MYSQL_HOST})

pom.xml:

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
<plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
        
hibernate intellij-idea maven spring
2021-11-18 20:51:06
1

La meilleure réponse

0

Si vous essayez d'utiliser les propriétés de pom.xml dans application.properties essayez ceci:

spring.datasource.url=jdbc:mysql://@MYSQL_HOST@?zeroDateTimeBehavior=convertToNull
2021-11-18 21:57:09

Non, je suis en train d'utiliser les propriétés de maven de configuration, à l'ide dans le coin supérieur droit, modifier la configuration, coureur, les variables d'environnement
Xavier Luzuriaga

Dans d'autres langues

Cette page est dans d'autres langues

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................