헤르메스 LIFE

[WARN] Cannot find template location: classpath:/templates/ 본문

Exception

[WARN] Cannot find template location: classpath:/templates/

헤르메스의날개 2023. 4. 13. 00:10
728x90

게시판을 작성해보려 합니다. 조금씩 살을 붙여나가 보려고 합니다.


개발환경

Spring Boot 2.7.9

lombok

devtools

postgresql

Gladle

Thymeleaf


아래와 같은 경고가 발생했습니다.

2023-04-12T23:16:10.277+09:00  WARN 19420 --- [  restartedMain] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates, check your Thymeleaf configuration, or set spring.thymeleaf.check-template-location=false)
2023-04-12T23:16:10.301+09:00  WARN 19420 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception with message: Failed to determine a suitable driver class
2023-04-12T23:16:10.303+09:00  INFO 19420 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-04-12T23:16:10.315+09:00  INFO 19420 --- [  restartedMain] .s.b.a.l.ConditionEvaluationReportLogger : 

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-04-12T23:16:10.329+09:00 ERROR 19420 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


Action:

Consider the following:
	If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
	If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

첫번째 문제는 Thymeleaf 문제 입니다.

Thymeleaf 환경은 templates 폴더가 존재해야 하는 모양입니다.

아래와 같이 폴더를 추가했습니다.

src/main/resources/templates 폴더 추가

src/main/resources/static 폴더 추가

templates 폴더를 사용하지 않으려면 아래와 같은 설정을 추가하면 된다고 가이드를 보여주네요.

spring.thymeleaf.check-template-location=false

Cannot find template location: classpath:/templates/ (please add some templates, check your Thymeleaf configuration, or set spring.thymeleaf.check-template-location=false)

두번째 문제는 DB 문제 입니다.

Dependency에 다음과 같은 설정이 있기때문에, DB를 연결해야 한다는 오류가 발생합니다.

implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'

OctopusBbsApplication.java

package octopus;

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

// @SpringBootApplication
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class OctopusBbsApplication {
    
    public static void main(String[] args) {
        SpringApplication.run(OctopusBbsApplication.class, args);
    }
    
}

아래의 설정을 추가하면, 일단 오류는 넘길 수 있습니다.

DB는 연결해야 합니다.

@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })


https://hermeslog.tistory.com/612

 

[Exception] Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

개발환경 Spring Boot 기본프로젝스 생성 후 Maven Install 하여 jar를 생성하던 중 아래와 같은 오류가 발생했습니다. 2022-06-25 15:43:30.351 ERROR 1452 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *********************

hermeslog.tistory.com

 

728x90