I have a project with spring, hibernate and flyway to create the database schema. So I have
spring.jpa.hibernate.ddl-auto: validate
in my application.properties file. This config works during normal run (after packaging the executable jar-file and running it from the terminal):
2014-10-06 10:06:17.863 INFO 7519 --- [ main] o.h.tool.hbm2ddl.SchemaValidator : HHH000229: Running schema validator
but is ignored when running tests via maven.
1804 [main] INFO o.h.tool.hbm2ddl.SchemaExport - HHH000227: Running hbm2ddl schema export
1805 [main] DEBUG org.hibernate.SQL - drop table test_entity if exists
1806 [main] DEBUG org.hibernate.SQL - drop sequence hibernate_sequence
1807 [main] DEBUG org.hibernate.SQL - create table test_entity (id bigint not null, name varchar(255), primary key (id))
1807 [main] DEBUG org.hibernate.SQL - create sequence hibernate_sequence
1808 [main] INFO o.h.tool.hbm2ddl.SchemaExport - HHH000230: Schema export complete
The main difference with the official flyway-sample seems in the I don't use the spring-boot provided maven-parent.
The complete project is here
So in a spring boot application, application. properties file is used to write the application-related property into that file. This file contains the different configuration which is required to run the application in a different environment, and each environment will have a different property defined by it.
Step 1 − After creating an executable JAR file, run it by using the command java –jar <JARFILE>. Step 2 − Use the command given in the screenshot given below to change the port number for Spring Boot application by using command line properties.
properties file in the classpath (src/main/resources/application. properties).
Spring Boot provides another file to configure the properties is called yml file. The Yaml file works because the Snake YAML jar is present in the classpath. Instead of using the application. properties file, we can also use the application.
Your test isn't using Spring Boot (it needs to use @SpringApplicationConfiguration
instead of @ContextConfiguration
, or declare the appropriate listeners).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With