programing

spring.data source의 가능한 값은 무엇입니까?초기화 모드?

jooyons 2023. 7. 24. 22:28
반응형

spring.data source의 가능한 값은 무엇입니까?초기화 모드?

Spring JPA에서 데이터베이스를 구성하고 있으며 가능한 값이 무엇인지 알고 싶습니다.spring.datasource.initialization-mode공통 속성이 있는 이 페이지를 찾았지만 모든 가능한 값을 제공하지는 않습니다.설정할 수 있는 모든 속성의 모든 가능한 값에 대한 문서가 있을 것으로 예상됩니다.

나는 나의 소품 섹션에 있는 부동산을 사용하고 있습니다.applicationContext.xml의 속성으로서entityManagerFactory

<util:properties id="props">
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQL82Dialect</prop>
    <prop key="hibernate.hbm2ddl.auto">create</prop>
    <prop key="hibernate.ddl-auto">create</prop>
    <prop key="spring.jpa.show-sql">true</prop>
    <prop key="spring.jpa.generate.ddl">true</prop>
    <prop key="spring.jpa.hibernate.ddl-auto">create</prop>
    <prop key="spring.datasource.initialization-mode">always</prop>
    <prop key="spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation">true</prop>
</util:properties>

다른 모든 것이 실패할 때, 당신은 "소스를 사용해, 루크!"를 기억합니다.값은 열거형의 Javadoc에 제공됩니다.DataSourceInitializationMode값은always,embedded그리고.never.

1년 가까이 늦게 들어와서 죄송합니다.설명한 것과 유사한 문제에 직면한 후Christine단서를 잡고 검색을 시작하기로 결정했습니다.source여기 https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/jdbc/DataSourceInitializationMode.html 링크에 다음 사항이 자세히 나와 있습니다.

열거 상수 요약 열거 상수

열거 상수 및 설명

항상 데이터 소스를 초기화합니다.

Embedded - 내장된 데이터 소스만 초기화합니다.

절대로 데이터 소스를 초기화하지 마십시오.

스프링 거동은 스프링 버전 2.7 버전에서 스프링 버전에 따라 달라집니다.

  1. Spring schema.sql 및 data를 사용하여 테이블을 만듭니다.Embedded i.e 메모리 데이터베이스 spring.dllsource.url=jdbc:h2:mem:somebofyours에 대한 클래스 경로의 sql

다음 구성을 시도해 보았습니다.

  1. 파일 기반 H2 만들기

    spring.springsource.url=jdbc:h2:file:~/db/eesandb spring.jpa.generate-ddl=true spring.jpa.dl.auto=filename

위의 조합이 무엇이든 스키마를 만들거나 실행하지 않았습니다.2.7.4의 sql

  1. 다음 속성 spring.sql.init.mode는 schema.sql 및 data를 참조하여 DDL,DML의 생성을 결정합니다.클래스 경로의 sql

예: spring.sql.init.mode = 항상(또는) spring.sysource.initialization-mode=항상.

유사한 게시물을 방문하십시오. Spring Boot 2.0 응용 프로그램이 schema.sql을 실행하지 않는 이유는 무엇입니까?

간단히 말해, 세 가지 옵션이 있습니다.always,embedded그리고.never.

참고: 속성spring.datasource.initialization-mode구식입니다.고려해 보는 것이 좋을 것입니다.spring.sql.init.mode대신 새로운 프로젝트를 위해.

오래된 것의 출처

/*
 * Copyright 2012-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.boot.jdbc;

/**
 * Supported {@link javax.sql.DataSource} initialization modes.
 *
 * @author Vedran Pavic
 * @author Stephane Nicoll
 * @since 2.0.0
 * @see AbstractDataSourceInitializer
 */
public enum DataSourceInitializationMode {

    /**
     * Always initialize the datasource.
     */
    ALWAYS,

    /**
     * Only initialize an embedded datasource.
     */
    EMBEDDED,

    /**
     * Do not initialize the datasource.
     */
    NEVER

}

새로운 소식통

/*
 * Copyright 2012-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.boot.sql.init;

/**
 * Supported database initialization modes.
 *
 * @author Andy Wilkinson
 * @since 2.5.1
 * @see AbstractScriptDatabaseInitializer
 */
public enum DatabaseInitializationMode {

    /**
     * Always initialize the database.
     */
    ALWAYS,

    /**
     * Only initialize an embedded database.
     */
    EMBEDDED,

    /**
     * Never initialize the database.
     */
    NEVER

}

언급URL : https://stackoverflow.com/questions/53922279/what-are-the-possible-values-of-spring-datasource-initialization-mode

반응형