ERP Project

뷰페이지 구성 에러 해결(2)

kwh_coding 2023. 7. 28. 13:35

우선 에러 페이지는 이러 했다.

MyBatisExceptionTranslator.translateExceptionIfPossible

 

즉, 데이터베이스와의 연동시 문제가 발생한 것이다. 

그래서 바로 properties로 가보았다.

 

# port setting
server.port=10000

spring.output.ansi.enabled=always

spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:templates/views/
spring.thymeleaf.suffix=.html
spring.thymeleaf.view-names=thymeleaf/*

spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp


# spring-jdbc ??? ?? ?? ??? ??? ?? ??
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/mysql?useSSL=false&useUnicode=true&serverTimezone=Asia/Seoul
spring.datasource.username=root
spring.datasource.password=secret

# MyBatis ??(mapper) ?? ?? ??
# src/main/resources ??? ??? ??
mybatis.mapper-locations=classpath:mapper/**/*.xml

# ?? ??? ??
# app.upload.path = upload

사용한 데이터베이스는 MySQL

tool은 DBeaver이다.

 

그동안 OracleDB와 SQLDeveloper만 사용해 오다가 처음으로 바꿔봤다. (새로

 

그리고 캡쳐는 못했지만 다른 에러페이지에서 이런 에러 내용이 있었다.

Table 'mysql.Erp_Comcode' doesn't exist 

 

이걸 보고 나는 테이블명이 Erp_Comcode이고, mapper.xml에 sql문도 대소문자 틀린 것 없이 잘 적었는데 왜 테이블명 앞에 자동으로 mysql. 을 붙이는가 하고 생각했다.

 

그래서 이래저래 구글링을 해봤는데 원하는 결과가 나오질 않던 와중에 찾은 해결법은

 

spring.datasource.url=jdbc:mysql://localhost:3306/mysql?useSSL=false&useUnicode=true&serverTimezone=Asia/Seoul

이 url에 있는 mysql부분을 자신의 데이터베이스명으로 적어줘야 하는 것이었다. 

즉, 나같은 경우에는 mysql이 아닌 erp로 바꿔서

 

# port setting
server.port=10000

spring.output.ansi.enabled=always

spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:templates/views/
spring.thymeleaf.suffix=.html
spring.thymeleaf.view-names=thymeleaf/*

spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp


# spring-jdbc ??? ?? ?? ??? ??? ?? ??
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/erp?useSSL=false&useUnicode=true&serverTimezone=Asia/Seoul
spring.datasource.username=root
spring.datasource.password=dnehd1008@

# MyBatis ??(mapper) ?? ?? ??
# src/main/resources ??? ??? ??
mybatis.mapper-locations=classpath:mapper/**/*.xml

# ?? ??? ??
# app.upload.path = upload

이렇게 변경을 했더니 에러없이 잘 해결이 되었다. ^^