【问题标题】:Spring boot : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabledSpring boot:启动 ApplicationContext 时出错。要显示条件报告,请在启用“调试”的情况下重新运行您的应用程序
【发布时间】:2021-03-21 01:07:56
【问题描述】:

我是 Java 和 Spring boot 的新手,我想创建一个显示 HTML 页面的程序, 当我使用这个时:

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

一切都很好,我首先有登录页面,然后是我创建的 HTML 页面

但是当我删除安全性的依赖时(因为我不需要它,我想直接显示我的 HTML 页面),它给了我一个错误

should i change the place of the AppController ?

【问题讨论】:

  • 所以,我运行您的代码,并在删除一些依赖项后,它开始工作。您已经实现了很多不需要的依赖项。始终添加必要的最小依赖项。请发布您的错误,以便我可以调试究竟是什么导致它。如果你刚开始使用java和spring,尽量使用内存数据库h2,不要导入任何安全依赖。
  • 你在使用 Postgres 吗?

标签: java html spring


【解决方案1】:

而不是

<artifactId>spring-boot-starter-security</artifactId>

使用

<artifactId>spring-boot-starter-web</artifactId>

【讨论】:

  • 为什么把repository和controller放到test src文件夹下?这仅用于测试
  • 我现在把它放在包 "com.example.TEST_WEB" 和 tamplates 中的索引页中,但仍然有相同的问题
  • 你能分享你的项目吗?
  • 请分享 Github 链接。
猜你喜欢
  • 2018-10-04
  • 2021-06-09
  • 1970-01-01
  • 2023-02-15
  • 1970-01-01
  • 2018-12-15
  • 1970-01-01
  • 2018-09-07
  • 2020-02-23
相关资源
最近更新 更多