我在我的應用程序屬性文件中使用了下面的設置。但仍然無法在h2控制檯中看到我的表格。從H2連接到H2數據庫控制檯
application.properties
logging.level.org.springframework.web=INFO
spring.datasource.url=jdbc:h2:mem:challenge;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MV_STORE=FALSE
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.schema=classpath:/schema.sql
spring.datasource.data=classpath:/data.sql
spring.h2.console.enabled=true
spring.h2.console.path=/h2
server.port = 8080
我使用了字符串jdbc:h2:mem:challenge;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MV_STORE=FALSE
在JDBC URL H2控制檯上登錄。然而,我沒有看到任何表
下面是我Graddle文件
buildscript {
ext {
springBootVersion = '1.4.4.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'challenge'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-jdbc')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-web')
runtime('org.springframework.boot:spring-boot-devtools')
runtime('com.h2database:h2')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
以下是實現Springsecurity我的春天啓動的應用程序
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/h2/*").permitAll();
http.csrf().disable();
http.headers().frameOptions().disable();
}
}
[查看H2或HSQLDB內存數據庫的內容]的可能重複(https://stackoverflow.com/questions/7309359/view-content-of-h2-or-hsqldb-in-memory-database) –
感謝您的意見。但我確實閱讀了所有其他文章,但他們都沒有解決我的問題。我已經啓動了我的Spring啓動應用程序,它基本上是一個連接到H2數據庫並獲取所有信息的Web服務。 web服務正在顯示信息,但是當我登錄到H2控制檯時,我沒有看到任何表或數據庫 – Vinayak
請顯示您的pom或gradle –