When introducing JOOQ to Spring boot, a story that was dealt with because an error occurred around Liquibase

background

I'm studying Spring boot.

is.

I wanted to write SQL method-based while studying Spring boot

Although I had a simple DB access with Spring default JPA, When I joined the table, I felt like I wasn't good at it. .. .. Recalling that I used to write method-based SELECT statements at work in the past I searched for a similar library.

Is there a query builder type ORM called ** JOOQ **? I noticed that, so I introduced it.

Introduction method

I will omit it. While using Postgres, I didn't have much trouble with the automatic generation of table-related source code for the tables in the target database.

An error has occurred!

There seems to be no compilation error, so when I tried to start the WEB application, the following error occurred.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.ChangeLogParseException: Error parsing classpath:/db/changelog/db.changelog-master.yaml
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1108) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at jp.ken.PasswordmanagerApplication.main(PasswordmanagerApplication.java:10) ~[main/:na]
Caused by: liquibase.exception.ChangeLogParseException: Error parsing classpath:/db/changelog/db.changelog-master.yaml
	at liquibase.parser.core.yaml.YamlChangeLogParser.parse(YamlChangeLogParser.java:83) ~[liquibase-core-3.8.7.jar:na]
	at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:217) ~[liquibase-core-3.8.7.jar:na]
	at liquibase.Liquibase.update(Liquibase.java:190) ~[liquibase-core-3.8.7.jar:na]
	at liquibase.Liquibase.update(Liquibase.java:179) ~[liquibase-core-3.8.7.jar:na]
	at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:366) ~[liquibase-core-3.8.7.jar:na]
	at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:314) ~[liquibase-core-3.8.7.jar:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	... 18 common frames omitted
Caused by: java.io.FileNotFoundException: class path resource [db/changelog/db.changelog-master.yaml] cannot be resolved to URL because it does not exist
	at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:195) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
	at liquibase.integration.spring.SpringLiquibase$SpringResourceOpener.getResourcesAsStream(SpringLiquibase.java:613) ~[liquibase-core-3.8.7.jar:na]
	at liquibase.util.StreamUtil.singleInputStream(StreamUtil.java:186) ~[liquibase-core-3.8.7.jar:na]
	at liquibase.parser.core.yaml.YamlChangeLogParser.parse(YamlChangeLogParser.java:26) ~[liquibase-core-3.8.7.jar:na]
	... 25 common frames omitted

What is this? .. .. What is Liquibase? : Rolling_eyes:

With the wisdom of our predecessors, https://qiita.com/opengl-8080/items/37beac5e210f5363af4b

Roughly, it looks like a DB management tool. It seems convenient, but I don't need it now. So, can't we manage to get through?

I tried the following settings while checking

  1. Create a db folder in src / main / resources
  2. Create a file called db.changelog-master.yaml in the db folder
  3. Added to application.properties

Contents of db.changelog-master.yaml

db.changelog-master.yaml


databaseChangeLog:
  - changeSet:
       author: authorName
       id: changelog-1.0

Even if I emptied the file or left "databaseChangeLog:", an error occurred, so I searched for the minimum required and found it as above.

application.properties Addendum

application.properties


spring.liquibase.change-log=classpath:db/db.changelog-master.yaml

I'll specify the above yaml.

You can find out how to create a file at the following site. https://stackoverflow.com/questions/41990295/java-illegalstateexception-cannot-find-changelog-location-class-path-resourc

Also, the minimum required yaml element is inferred from the following site. https://qiita.com/opengl-8080/items/37beac5e210f5363af4b

The error has been resolved above! Congratulations, congratulations.

Recommended Posts

When introducing JOOQ to Spring boot, a story that was dealt with because an error occurred around Liquibase
A memo that I was addicted to when making batch processing with Spring Boot
What I was addicted to when developing a Spring Boot application with VS Code
A site that was easy to understand when I was a beginner when I started learning Spring Boot
When trying to insert a specific gem (levenshtein) with Docker, an error occurred without ruby-dev
A story that made me regret when a "NotReadablePropertyException" occurred during the development of the Spring Boot application.
[Unauthorized Operation] A memorandum because an error occurred when creating an EC2 instance.
Story when moving from Spring Boot 1.5 to 2.1
An error occurred when executing a function from MyBatis with the OUT parameter set to CURSOR in PostgreSQL.
[Error resolution] Occurs when trying to build an environment for spring with docker
When you want to notify an error somewhere when using graphql-spring-boot in Spring Boot
A story that I was really into when I did triple DES with ruby
From creating a Spring Boot project to running an application with VS Code
A story that got stuck with an error during migration in docker PHP laravel
A story that failed when connecting to CloudSQL by running Sprint-boot with kubernetes (GKE)
[Spring Boot] The story that the bean of the class with ConfigurationProperties annotation was not found
Error handling when the maximum file size is exceeded when uploading a file with Spring Boot
A story I was addicted to when getting a key that was automatically tried on MyBatis
A memorandum when creating a REST service with Spring Boot
Java: A story that made me feel uncomfortable when I was taught to compare strings with equals for no reason.
The story that led to solving the error because postgres did not start with docker-compose up
A story stuck with an error when building Vagrant + Virtulbox CentOS7.8 and creating a shared folder
When I personally developed with Rails, it was a painful story that Rails was hit very much
What I fixed when updating to Spring Boot 1.5.12 ・ What I was addicted to
An error occurred because only_full_group_by of sql_mode was not observed.
A validation error occurred when saving to the intermediate table.
A story that I struggled to challenge a competition professional with Java
I get a 404 error when testing forms authentication with Spring Security
A story of connecting to a CentOS 8 server with an old Ansible
How to create your own Controller corresponding to / error with Spring Boot
[Rejected] A memorandum because an error occurred during deployment on Heroku
Sample code to unit test a Spring Boot controller with MockMvc
When you receive a call, send an SMS to that number
Resolved the error that occurred when trying to use Spark in an environment where Java 8 and Java 11 coexist.
How to set the default fetch size when jOOQ gets an OOM error when fetching a huge result set
The story of making it possible to build a project that was built by Maven with Ant
[Spring Boot] Precautions when developing a web application with Spring Boot and placing war on an independent Tomcat server
A story that I was addicted to twice with the automatic startup setting of Tomcat 8 on CentOS 8