jojoldu / freelec-springboot2-webservice

1.07k stars 461 forks source link

[오류] p.116 H2 DB 연결 불가(not found) #608

Open DevOps-chdkim opened 3 years ago

DevOps-chdkim commented 3 years ago

기존에 올라온 질문이 아닌지 먼저 검색해주세요!

가장 자주 나온 제보

어떤 오류인가요?

Application.main() 실행 후 아래 메세지 출력(정상적으로 된 것으로 보입니다.)

오후 5:49:50: Executing task 'Application.main()'...

Task :compileJava UP-TO-DATE Task :processResources UP-TO-DATE Task :classes UP-TO-DATE

Task :Application.main()

. _ _ /\ / '_ () \ \ \ \ ( ( )\ | ' | '| | ' \/ ` | \ \ \ \ \/ _)| |)| | | | | || (| | ) ) ) ) ' |__| .|| ||| |\, | / / / / =========|_|==============|__/=//// :: Spring Boot :: (v2.4.1)

2021-03-30 17:49:52.272 INFO 21708 --- [ main] com.jojoldu.book.springboot.Application : Starting Application using Java 10.0.2 on DESKTOP-RKM8H0A with PID 21708 (D:\springboot-work\freelec-springboot2-webservice\build\classes\java\main started by chdkim in D:\springboot-work\freelec-springboot2-webservice) 2021-03-30 17:49:52.278 INFO 21708 --- [ main] com.jojoldu.book.springboot.Application : No active profile set, falling back to default profiles: default 2021-03-30 17:49:53.256 INFO 21708 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2021-03-30 17:49:53.322 INFO 21708 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 57 ms. Found 1 JPA repository interfaces. 2021-03-30 17:49:54.425 INFO 21708 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2021-03-30 17:49:54.435 INFO 21708 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2021-03-30 17:49:54.436 INFO 21708 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41] 2021-03-30 17:49:54.652 INFO 21708 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2021-03-30 17:49:54.653 INFO 21708 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2279 ms 2021-03-30 17:49:54.767 INFO 21708 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2021-03-30 17:49:55.118 INFO 21708 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2021-03-30 17:49:55.134 INFO 21708 --- [ main] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:2e85f9a2-c551-4d1e-9a80-67555c2ff99a' 2021-03-30 17:49:55.492 INFO 21708 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2021-03-30 17:49:55.561 INFO 21708 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.25.Final 2021-03-30 17:49:55.738 INFO 21708 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} 2021-03-30 17:49:55.905 INFO 21708 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect Hibernate: drop table if exists posts CASCADE Hibernate: create table posts (id bigint generated by default as identity, author varchar(255), content TEXT not null, title varchar(500) not null, primary key (id)) 2021-03-30 17:49:56.631 INFO 21708 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] 2021-03-30 17:49:56.639 INFO 21708 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2021-03-30 17:49:57.077 WARN 21708 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning 2021-03-30 17:49:57.234 INFO 21708 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2021-03-30 17:49:57.455 WARN 21708 --- [ main] o.s.b.a.m.MustacheAutoConfiguration : Cannot find template location: classpath:/templates/ (please add some templates, check your Mustache configuration, or set spring.mustache.check-template-location=false) 2021-03-30 17:49:57.581 INFO 21708 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2021-03-30 17:49:57.595 INFO 21708 --- [ main] com.jojoldu.book.springboot.Application : Started Application in 5.836 seconds (JVM running for 6.43) 2021-03-30 17:53:34.868 INFO 21708 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet' 2021-03-30 17:53:34.868 INFO 21708 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet' 2021-03-30 17:53:34.873 INFO 21708 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 4 ms

오류설명: H2 콘솔 접속까지는 되나 mem:testdb가 없다고 나옵니다.

프로젝트 주소

오류 로그

Database "mem:testdb" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200] 90149/90149 (Help) org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database "mem:testdb" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200] at org.h2.message.DbException.getJdbcSQLException(DbException.java:622) at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) at org.h2.message.DbException.get(DbException.java:205) at org.h2.message.DbException.get(DbException.java:181) at org.h2.engine.Engine.openSession(Engine.java:71) at org.h2.engine.Engine.openSession(Engine.java:192) at org.h2.engine.Engine.createSessionAndValidate(Engine.java:171) at org.h2.engine.Engine.createSession(Engine.java:166) at org.h2.engine.Engine.createSession(Engine.java:29) at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:340) at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:173) at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:152) at org.h2.Driver.connect(Driver.java:69) at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:309) at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:289) at org.h2.server.web.WebServer.getConnection(WebServer.java:785) at org.h2.server.web.WebApp.test(WebApp.java:947) at org.h2.server.web.WebApp.process(WebApp.java:238) at org.h2.server.web.WebApp.processRequest(WebApp.java:173) at org.h2.server.web.WebServlet.doGet(WebServlet.java:129) at org.h2.server.web.WebServlet.doPost(WebServlet.java:166) at javax.servlet.http.HttpServlet.service(HttpServlet.java:652) at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.base/java.lang.Thread.run(Thread.java:844)

MJ-0701 commented 3 years ago

프로퍼티에 spring.datasource.url=jdbc:h2:mem:testdb 하셨나요?

DevOps-chdkim commented 3 years ago

감사합니다.