简体   繁体   English

Spring 启动 - aplication.properties 中未使用的属性

[英]Spring boot - unused properties in aplication.properties

Do you know why IntelliJ IDEA Community Edition 2022.02.1 does not see properties in aplication.properties?你知道为什么 IntelliJ IDEA Community Edition 2022.02.1 在 aplication.properties 中看不到属性吗? enter image description here Does the compiler recognize and use them even though it cannot see them? enter image description here编译器是否识别并使用它们,即使它看不到它们? If you need more information about this problem ask me I will write back as soon as possible.如果您需要有关此问题的更多信息,请问我,我会尽快回信。

This is my pom.xml这是我的 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>18</java.version>
    </properties>
    <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>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Spring & Spring Boot assistance comes with IntelliJ IDEA Ultimate which can detect all your Beans (along with its usages and injections), Rest Controller Endpoints, Application Properties (along with the classes that use those properties), Spring relevant auto completions, etc. The said features are not available in IntelliJ IDEA Community Edition which is why you see those application properties as unused. Spring & Spring Boot assistance comes with IntelliJ IDEA Ultimate which can detect all your Beans (along with its usages and injections), Rest Controller Endpoints, Application Properties (along with the classes that use those properties), Spring relevant auto completions, etc. The IntelliJ IDEA Community Edition中不提供上述功能,这就是为什么您将这些应用程序属性视为未使用的原因。 Still, in reality, it is being used and your application should pick them up just fine (assuming you've set up things correctly).尽管如此,实际上,它正在被使用,您的应用程序应该可以很好地选择它们(假设您已正确设置)。

These missing features however should not stop you from developing Spring Boot (or any JVM frameworks for that matter) applications using IntelliJ IDEA Community Edition.但是,这些缺失的功能不应阻止您使用 IntelliJ IDEA 社区版开发 Spring Boot(或任何 JVM 框架)应用程序。

As the application.properties was not in a source folder, with the name src/main/resource maybe that's it由于 application.properties 不在源文件夹中,名称 src/main/resource 可能就是这样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM