简体   繁体   English

如何修复“启动 ApplicationContext 时出错。要显示条件报告,请在启用“调试”的情况下重新运行您的应用程序。”

[英]how to fix "Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled."

I'm getting this error when trying to run my Java code with Maven using Intellij:尝试使用 Intellij 使用 Maven 运行我的 Java 代码时出现此错误:

Error starting ApplicationContext.启动 ApplicationContext 时出错。 To display the conditions report re-run your application with 'debug' enabled.要显示条件报告,请在启用“调试”的情况下重新运行您的应用程序。

2022-06-29 23:39:33.179 ERROR 4068 --- [ main] osboot.SpringApplication: Application run failed 2022-06-29 23:39:33.179 错误 4068 --- [main] osboot.SpringApplication: 应用程序运行失败

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.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.server.app</groupId>
    <artifactId>rest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>RestAPI</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <!--> mysql on my computer version, the version should be true<-->
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.26</version>
        </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>

RestApi.java RestApi.java


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class RestApiApplication {

    public static void main(String[] args) {
        SpringApplication.run(RestApiApplication.class, args);
    }

}

User.java用户.java

package com.server.app.rest.Models;

import javax.persistence.*;
// mysql columns, connection
@Entity
public class User {
    // id is primary key
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;
    @Column
    private String firstName;
    @Column
    private String lastName;
    @Column
    private String job;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }
}
 

UserRepo.java UserRepo.java


import com.server.app.rest.Models.User;
import org.springframework.data.jpa.repository.JpaRepository;

//userrepo get features from jpa.
public interface UserRepo extends JpaRepository<User, Long> {
}

properies属性

spring.datasource.url=jdbc:mysql://localhost:3306/crudusers?allowPublicKeyRetrieval=true&useSSL=false spring.datasource.url=jdbc:mysql://localhost:3306/crudusers?allowPublicKeyRetrieval=true&useSSL=false

spring.datasource.username=username spring.datasource.username=用户名

spring.datasource.password=password spring.datasource.password=密码

spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update

ApiControllers.java ApiControllers.java


import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ApiControllers {
    // first connect the page, except this- / - get error
    @GetMapping(value = "/")
    public String getPage(){

        return "Welcome";
    }
}

Finally i solved the problem.最后我解决了这个问题。 The problem was the wrong password.问题是密码错误。 I wrote the right password, then fixed the error.我写了正确的密码,然后修复了错误。

暂无
暂无

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

相关问题 我收到“启动 ApplicationContext 时出错。 要显示条件报告,请在启用“调试”的情况下重新运行您的应用程序。” 解决方案? - I am getting “Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.” Solution for this? 启动 ApplicationContext 时出错。 要显示条件报告,请在启用“调试”的情况下重新运行您的应用程序 - Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled Spring 启动:启动 ApplicationContext 时出错。 要显示条件报告,请在启用“调试”的情况下重新运行您的应用程序 - Spring boot : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled “启动 ApplicationContext 时出错。 在运行 Spring 启动项目时,显示条件报告重新运行您的应用程序并启用“调试” - “Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled” when run Spring Boot project 启动ApplicationContext时出错。 要显示条件报告,请在spring-boot中启用“ debug”重新运行您的应用程序 - Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled in spring-boot 在 Spring Boot 中继续获取“启动 ApplicationContext 时出错。要显示条件报告,请在启用“调试”的情况下重新运行您的应用程序” - Keep Getting "Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled" in Spring Boot Spring Boot 请求:“在启用 &#39;debug&#39; 的情况下重新运行您的应用程序” - 我该怎么做? - Spring Boot requests: to "re-run your application with 'debug' enabled" - how do I? 错误起动应用上下文到显示最自动配置报告 - error-starting-applicationcontext-to-display-the-auto-configuration-report Java Spring-启动ApplicationContext时出错。 创建名称为&#39;entityManagerFactory&#39;的bean时出错 - Java Spring - Error starting ApplicationContext. Error creating bean with name 'entityManagerFactory' 如何从 Eclipse 正确重新运行 Spring Boot 应用程序? - How to properly re-run Spring Boot application from Eclipse?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM