Spring Boot / Spring Import.sql data does not start Spring -Boot-1.0.0.RC1

I followed the development of Spring Boot and sometimes between the original version 0.0.5-BUILD-SNAPSHOTand the current version that I use. 1.0.0.RC1I no longer run my import.sqlscript.

Here is my configuration for LocalContainerEntityManagerandJpaVendorAdapter

@Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactory(
            DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) {
        LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
        lef.setDataSource(dataSource);
        lef.setJpaVendorAdapter(jpaVendorAdapter);
        lef.setPackagesToScan("foo.*");
        return lef;
    }

    @Bean
    public JpaVendorAdapter jpaVendorAdapter() {
        HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
        hibernateJpaVendorAdapter.setShowSql(true);
        hibernateJpaVendorAdapter.setGenerateDdl(true);
        hibernateJpaVendorAdapter.setDatabase(Database.POSTGRESQL);
        return hibernateJpaVendorAdapter;
    }

Interestingly, it hibernate.hbm2ddl.autostill works, which, I think, is part of my definitionSpringBootServletInitializer

@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application extends SpringBootServletInitializer {

However, I also noticed that the generated tables no longer have underlining and change their shape when generating?

However, this may be the result of updating my version org.postgresqlas follows:

Earlier:

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>9.2-1004-jdbc41</version>
</dependency>

Now:

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>9.3-1100-jdbc41</version>
</dependency>

I also had to change pggetserialsequenceto pg_get_serial_sequenceto run the script from pgadmin?

, , , , , import.sql.

: https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-data-jpa

import.sql 1.0.0-BUILD-SNAPSHOT

+4
3

import.sql script - , ( Spring Spring Boot). , , , ddl-auto . Spring Boot , spring.jpa.hibernate.ddl-auto "create" "create-drop" ( Boot , , postgres).

SQL script, Spring Boot Hibernate, classpath:schema.sql ( classpath:schema-<platform>.sql, <platform> "postgres" ).

, , , JpaVendorAdapter, LocalContainerEntityManagerFactoryBean ( persistence.xml), Boot . @EntityScan ( Spring Boot).

Boot 1.0.0.RC1 ( postgres). , RC2, Hibernate, spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy.

+12

, . sql script . "import.sql" " schema.sql", . , . - https://github.com/sidnan/spring-batch-example

+3

, , , data.sql / . data.sql (: Spring, src/main/resources).

, ddl-auto = create-drop, , .

, , spring.datasource.data​​strong > . : http://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html

. schema.sql . , , Hibernate Java- . doc:

If you want to use schema.sql initialization in a JPA application (with Hibernate), then ddl-auto = create-drop will result in errors if Hibernate tries to create the same tables. To avoid these errors, set ddl-auto explicitly "(preferred) or" none "

0
source

Source: https://habr.com/ru/post/1524217/


All Articles