Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaSpring在其中放置自定义属性文件_Java_Spring - Fatal编程技术网

JavaSpring在其中放置自定义属性文件

JavaSpring在其中放置自定义属性文件,java,spring,Java,Spring,我正在尝试创建一个简单的注册页面。我目前正在尝试获取有关帐户激活链接发送地址的数据。为此,我创建了.properties文件,并将其放在“src/main/resources”文件夹中。不幸的是,在启动应用程序并尝试下载数据后,我遇到了一个错误 为测试创建的我的类: public class GetConfig { public void getProperites() { try (InputStream input = getClass().getR

我正在尝试创建一个简单的注册页面。我目前正在尝试获取有关帐户激活链接发送地址的数据。为此,我创建了.properties文件,并将其放在
“src/main/resources”
文件夹中。不幸的是,在启动应用程序并尝试下载数据后,我遇到了一个错误

为测试创建的我的类:

 public class GetConfig {
        public void getProperites() {
            try (InputStream input = getClass().getResourceAsStream("/emailconfig.properties")) {

                Properties prop = new Properties();

                // load a properties file
                prop.load(input);

                // get the property value and print it out
                System.out.println(prop.getProperty("mail.adress"));
                System.out.println(prop.getProperty("mail.smtp.host"));
                System.out.println(prop.getProperty("mail.smtp.por"));
                System.out.println(prop.getProperty("mail.smtp.ssl.enable"));
                System.out.println(prop.getProperty("mail.smtp.auth"));

            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
Exception in thread "main" java.lang.NullPointerException
    at java.util.Properties$LineReader.readLine(Properties.java:434)
    at java.util.Properties.load0(Properties.java:353)
    at java.util.Properties.load(Properties.java:341)
    at com.project.gym.mail.GetConfig.getProperites(GetConfig.java:19)
    at com.project.gym.GymApplication.main(GymApplication.java:21)
mail.adress=myaddress@gmail.com
mail.smtp.host=smtp.gmail.com
mail.smtp.port=465
mail.smtp.ssl.enable=true
mail.smtp.auth=true
<?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.2.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.project</groupId>
    <artifactId>gym</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>gym</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <vaadin.version>14.1.5</vaadin.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>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</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>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.vaadin.stefan</groupId>
            <artifactId>fullcalendar2</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>javax.mail</artifactId>
            <version>1.6.2</version>
        </dependency>

    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>${vaadin.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

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

        </plugins>
    </build>



    <repositories>
        <repository>
            <id>vaadin-addons</id>
            <url>https://maven.vaadin.com/vaadin-addons</url>
        </repository>
    </repositories>

</project>
错误:

 public class GetConfig {
        public void getProperites() {
            try (InputStream input = getClass().getResourceAsStream("/emailconfig.properties")) {

                Properties prop = new Properties();

                // load a properties file
                prop.load(input);

                // get the property value and print it out
                System.out.println(prop.getProperty("mail.adress"));
                System.out.println(prop.getProperty("mail.smtp.host"));
                System.out.println(prop.getProperty("mail.smtp.por"));
                System.out.println(prop.getProperty("mail.smtp.ssl.enable"));
                System.out.println(prop.getProperty("mail.smtp.auth"));

            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
Exception in thread "main" java.lang.NullPointerException
    at java.util.Properties$LineReader.readLine(Properties.java:434)
    at java.util.Properties.load0(Properties.java:353)
    at java.util.Properties.load(Properties.java:341)
    at com.project.gym.mail.GetConfig.getProperites(GetConfig.java:19)
    at com.project.gym.GymApplication.main(GymApplication.java:21)
mail.adress=myaddress@gmail.com
mail.smtp.host=smtp.gmail.com
mail.smtp.port=465
mail.smtp.ssl.enable=true
mail.smtp.auth=true
<?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.2.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.project</groupId>
    <artifactId>gym</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>gym</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <vaadin.version>14.1.5</vaadin.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>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</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>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.vaadin.stefan</groupId>
            <artifactId>fullcalendar2</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>javax.mail</artifactId>
            <version>1.6.2</version>
        </dependency>

    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>${vaadin.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

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

        </plugins>
    </build>



    <repositories>
        <repository>
            <id>vaadin-addons</id>
            <url>https://maven.vaadin.com/vaadin-addons</url>
        </repository>
    </repositories>

</project>
emailconfig.properties文件:

 public class GetConfig {
        public void getProperites() {
            try (InputStream input = getClass().getResourceAsStream("/emailconfig.properties")) {

                Properties prop = new Properties();

                // load a properties file
                prop.load(input);

                // get the property value and print it out
                System.out.println(prop.getProperty("mail.adress"));
                System.out.println(prop.getProperty("mail.smtp.host"));
                System.out.println(prop.getProperty("mail.smtp.por"));
                System.out.println(prop.getProperty("mail.smtp.ssl.enable"));
                System.out.println(prop.getProperty("mail.smtp.auth"));

            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
Exception in thread "main" java.lang.NullPointerException
    at java.util.Properties$LineReader.readLine(Properties.java:434)
    at java.util.Properties.load0(Properties.java:353)
    at java.util.Properties.load(Properties.java:341)
    at com.project.gym.mail.GetConfig.getProperites(GetConfig.java:19)
    at com.project.gym.GymApplication.main(GymApplication.java:21)
mail.adress=myaddress@gmail.com
mail.smtp.host=smtp.gmail.com
mail.smtp.port=465
mail.smtp.ssl.enable=true
mail.smtp.auth=true
<?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.2.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.project</groupId>
    <artifactId>gym</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>gym</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <vaadin.version>14.1.5</vaadin.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>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</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>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.vaadin.stefan</groupId>
            <artifactId>fullcalendar2</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>javax.mail</artifactId>
            <version>1.6.2</version>
        </dependency>

    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>${vaadin.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

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

        </plugins>
    </build>



    <repositories>
        <repository>
            <id>vaadin-addons</id>
            <url>https://maven.vaadin.com/vaadin-addons</url>
        </repository>
    </repositories>

</project>
据我所知,Eclipse找不到我的文件我的问题来了,我应该把我的文件放在哪里才能看到,或者我应该如何更改它的路径以使其正确?

编辑1:

 public class GetConfig {
        public void getProperites() {
            try (InputStream input = getClass().getResourceAsStream("/emailconfig.properties")) {

                Properties prop = new Properties();

                // load a properties file
                prop.load(input);

                // get the property value and print it out
                System.out.println(prop.getProperty("mail.adress"));
                System.out.println(prop.getProperty("mail.smtp.host"));
                System.out.println(prop.getProperty("mail.smtp.por"));
                System.out.println(prop.getProperty("mail.smtp.ssl.enable"));
                System.out.println(prop.getProperty("mail.smtp.auth"));

            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
Exception in thread "main" java.lang.NullPointerException
    at java.util.Properties$LineReader.readLine(Properties.java:434)
    at java.util.Properties.load0(Properties.java:353)
    at java.util.Properties.load(Properties.java:341)
    at com.project.gym.mail.GetConfig.getProperites(GetConfig.java:19)
    at com.project.gym.GymApplication.main(GymApplication.java:21)
mail.adress=myaddress@gmail.com
mail.smtp.host=smtp.gmail.com
mail.smtp.port=465
mail.smtp.ssl.enable=true
mail.smtp.auth=true
<?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.2.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.project</groupId>
    <artifactId>gym</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>gym</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <vaadin.version>14.1.5</vaadin.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>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</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>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.vaadin.stefan</groupId>
            <artifactId>fullcalendar2</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>javax.mail</artifactId>
            <version>1.6.2</version>
        </dependency>

    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>${vaadin.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

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

        </plugins>
    </build>



    <repositories>
        <repository>
            <id>vaadin-addons</id>
            <url>https://maven.vaadin.com/vaadin-addons</url>
        </repository>
    </repositories>

</project>
pom.xml:

 public class GetConfig {
        public void getProperites() {
            try (InputStream input = getClass().getResourceAsStream("/emailconfig.properties")) {

                Properties prop = new Properties();

                // load a properties file
                prop.load(input);

                // get the property value and print it out
                System.out.println(prop.getProperty("mail.adress"));
                System.out.println(prop.getProperty("mail.smtp.host"));
                System.out.println(prop.getProperty("mail.smtp.por"));
                System.out.println(prop.getProperty("mail.smtp.ssl.enable"));
                System.out.println(prop.getProperty("mail.smtp.auth"));

            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
Exception in thread "main" java.lang.NullPointerException
    at java.util.Properties$LineReader.readLine(Properties.java:434)
    at java.util.Properties.load0(Properties.java:353)
    at java.util.Properties.load(Properties.java:341)
    at com.project.gym.mail.GetConfig.getProperites(GetConfig.java:19)
    at com.project.gym.GymApplication.main(GymApplication.java:21)
mail.adress=myaddress@gmail.com
mail.smtp.host=smtp.gmail.com
mail.smtp.port=465
mail.smtp.ssl.enable=true
mail.smtp.auth=true
<?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.2.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.project</groupId>
    <artifactId>gym</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>gym</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <vaadin.version>14.1.5</vaadin.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>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</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>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.vaadin.stefan</groupId>
            <artifactId>fullcalendar2</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>javax.mail</artifactId>
            <version>1.6.2</version>
        </dependency>

    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>${vaadin.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

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

        </plugins>
    </build>



    <repositories>
        <repository>
            <id>vaadin-addons</id>
            <url>https://maven.vaadin.com/vaadin-addons</url>
        </repository>
    </repositories>

</project>
我开始出现以下错误:

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.project.gym.GymApplication]; nested exception is java.io.FileNotFoundException: class path resource [emailconfig.properties] cannot be opened because it does not exist
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:319) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE]
    at com.project.gym.GymApplication.main(GymApplication.java:18) [classes/:na]
Caused by: java.io.FileNotFoundException: class path resource [emailconfig.properties] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:159) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:99) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:73) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties(PropertiesLoaderUtils.java:59) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.core.io.support.ResourcePropertySource.<init>(ResourcePropertySource.java:67) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.core.io.support.DefaultPropertySourceFactory.createPropertySource(DefaultPropertySourceFactory.java:37) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.processPropertySource(ConfigurationClassParser.java:455) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:274) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:194) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:298) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:202) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:170) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    ... 13 common frames omitted
org.springframework.beans.factory.BeanDefinitionStoreException:无法解析配置类[com.project.gym.GymApplication];嵌套异常为java.io.FileNotFoundException:无法打开类路径资源[emailconfig.properties],因为它不存在
在org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184)~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:319)~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.context.annotation.ConfigurationClassPostProcessor.PostProcessBeandDefinitionRegistry(ConfigurationClassPostProcessor.java:236)~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.context.support.postprocessorregistrationlegate.invokeBeanDefinitionRegistryPostProcessors(postprocessorregistrationlegate.java:275)~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.context.support.postprocessorregistrationlegate.invokeBeanFactoryPostProcessors(postprocessorregistrationlegate.java:95)~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706)~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)~[spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE]
在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)[spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE]
位于org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)[spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE]
在org.springframework.boot.SpringApplication.run(SpringApplication.java:315)[spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE]
在org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)[spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE]
在org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)[spring-boot-2.2.3.RELEASE.jar:2.2.3.RELEASE]
在com.project.gym.GymApplication.main(GymApplication.java:18)[classes/:na]
原因:java.io.FileNotFoundException:无法打开类路径资源[emailconfig.properties],因为它不存在
在org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180)~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:159)~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:99)~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:73)~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties(PropertiesLoaderUtils.java:59)~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.core.io.support.ResourcePropertySource.(ResourcePropertySource.java:67)~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.core.io.support.DefaultPropertySourceFactory.CreatePropertySourceSource(DefaultPropertySourceFactory.java:37)~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.context.annotation.ConfigurationClassParser.processPropertySource(ConfigurationClassParser.java:455)~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:274)~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245)~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:194)~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:298)~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245)~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:202)~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
在org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:170)~[spring-context-5。