Reputation: 2050
I followed the next tutorial for h2 implementation. H2 works well, but the console isn't - the page isn't opened.
I tried many gifts, so my final application.properties looks so:
#Database settings
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=root
spring.datasource.password=password
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.data.jpa.repositories.bootstrap-mode=default
spring.h2.console.enabled=true
spring.h2.console.settings.web-allow-others=true
spring.datasource.generate-unique-name = false
spring.h2.console.path=/h2-console/
spring.jpa.hibernate.ddl-auto=update
spring.datasource.tomcat.connection-properties=useUnicode=true;characterEncoding=utf-8;
spring.datasource.sql-script-encoding=UTF-8
spring.jpa.open-in-view=false
spring.datasource.initialization-mode=always
#swagger
spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER
#Disable thymeleaf cashing
spring.template.cache = false;
dependencies:
ext {
spring_boot_version = '2.6.6'
}
implementation "org.springframework.boot:spring-boot-starter-parent:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-starter-data-jpa:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-starter-validation:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-starter-thymeleaf:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-starter-web:${spring_boot_version}"
runtimeOnly "com.h2database:h2:1.4.193"
....
The uri I try to open:
http://localhost:8080/h2-console
Upvotes: 1
Views: 1129
Reputation: 83
Could you try to add the following configuration to the security config?
http.authorizeRequests()
.antMatchers("/h2-console/**").permitAll()
Ideally, you need to config (depending on the spring boot version) to allow access to /h2-console URL. You can also publicise your security configuration so that I can have a look.
Upvotes: 0
Reputation: 36
Try this:
server.port=8080
spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE;
Upvotes: 1