ทำไมของตัวแปรสภาพแวดล้อมไม่ได้ทำงานในฤดูใบไม้ผลิ(maven)?

0

คำถาม

ฉันกำลังทำงานอยู่กับ intellij ฉันตั้งค่าตัวแปรสภาพแวดล้อมอยู่ใน Maven การปรับแต่งค่า(ด้านบนถูกเพิ่มการปรับแต่ง,เฮ้รันเน่อร์ตัวแปรสภาพแวดล้อม)

มันเหมือนว่ามันอ่านชื่อตัวแปรที่เป็นข้อความแทนที่จะเป็นตัวแปร ช่วยได้โปรด

โปรแกรมคุณสมบัติของ:

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

ตัวแปรสภาพแวดล้อมอง(ใน maven การปรับแต่ง):

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

ข้อความ:

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

คำตอบที่ดีที่สุด

0

ถ้าคุณกำลังพยายามจะใช้คุณสมบัติของจาก pom.xml ใน application.properties พยายามนี้:

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

ไม่ฉันกำลังพยายามใช้คุณสมบัติจาก maven การปรับแต่งใน intellij อยู่ทางด้านบนตรงหัวมุม,แก้ไขการปรับแต่ง,เฮ้รันเน่อร์ตัวแปรสภาพแวดล้อม
Xavier Luzuriaga

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

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

ดังอยู่ในนี้หมวดหมู่

ดังคำถามอยู่ในนี้หมวดหมู่