Where to put liquibase.properties file when using org.springframework.boot?

Viewed 268

I'm getting error trying to use local XSD file in changelog.xml (new security feature was introduced in ver 4.8)

Failed to read schema document 'dbchangelog-4.12.xsd', because 'file' access is not allowed due to restriction set by the accessExternalSchema property.

I know, that I need to create liquibase.properties file in the liquibase directory with

secureParsing="false"
accessExternalSchema="all"

but the question is: where to put this liquibase.properties file and how to make it work if liquibase is not installed on my Mac computer? I created this file and placed it in every folder of my project, but it does not work. Docker container builds this way:

mvn clean install -f pom.xml
docker build -t ${APP}:${VER} --build-arg APP=${APP} --build-arg VER=${VER} --build-arg JARSRC=${JARSRC} -f Dockerfile .

changelog.xml

<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                          dbchangelog-4.12.xsd"
    objectQuotingStrategy="QUOTE_ONLY_RESERVED_WORDS">

POM.XML

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.7.0</version>
            <relativePath/> 
        </parent>
    
 <properties>
    <java.version>11</java.version>
    <javax.validation.api.version>2.0.1.Final</javax.validation.api.version>
    <liquibase.version>4.12.0</liquibase.version>
    <hibernate-validator.version>6.2.1.Final</hibernate-validator.version>
    <javax.el.version>3.0.0</javax.el.version>
    <javax.jms.version>2.0.1</javax.jms.version>
    <google.libphonenumber.version>8.12.51</google.libphonenumber.version>
    <org.projectlombok.version>1.18.24</org.projectlombok.version>
    <build.helper.maven.plugin.version>3.3.0</build.helper.maven.plugin.version>
    <maven.surefire.version>3.0.0-M7</maven.surefire.version>
    <maven.surefire.plugin.version>3.0.0-M7</maven.surefire.plugin.version>
    <maven.failsafe.plugin.version>3.0.0-M7</maven.failsafe.plugin.version>
</properties>

<dependencies>
   <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-web</artifactId>
   </dependency>
   <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-test</artifactId>
       <scope>test</scope>
   </dependency>
   <dependency>
       <groupId>javax.validation</groupId>
       <artifactId>validation-api</artifactId>
       <version>${javax.validation.api.version}</version>
   </dependency>
   <dependency>
       <groupId>org.hibernate.validator</groupId>
       <artifactId>hibernate-validator</artifactId>
       <version>${hibernate-validator.version}</version>
   </dependency>
   <dependency>
       <groupId>org.glassfish</groupId>
       <artifactId>javax.el</artifactId>
       <version>${javax.el.version}</version>
   </dependency>
   <dependency>
       <groupId>com.googlecode.libphonenumber</groupId>
       <artifactId>libphonenumber</artifactId>
       <version>${google.libphonenumber.version}</version>
   </dependency>
   <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-data-jpa</artifactId>
   </dependency>
   <dependency>
       <groupId>org.postgresql</groupId>
       <artifactId>postgresql</artifactId>
   </dependency>
   <dependency>
       <groupId>com.h2database</groupId>
       <artifactId>h2</artifactId>
       <scope>test</scope>
   </dependency>
   <dependency>
       <groupId>org.projectlombok</groupId>
       <artifactId>lombok</artifactId>
       <version>${org.projectlombok.version}</version>
       <scope>provided</scope>
   </dependency>
   <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-devtools</artifactId>
   </dependency>
   <dependency>
       <groupId>org.liquibase</groupId>
       <artifactId>liquibase-core</artifactId>
       <version>${liquibase.version}</version>
   </dependency>
   <dependency>
       <groupId>org.apache.maven.surefire</groupId>
       <artifactId>surefire-api</artifactId>
       <version>${maven.surefire.version}</version>
   </dependency>
   <dependency>
       <groupId>javax.jms</groupId>
       <artifactId>javax.jms-api</artifactId>
       <version>${javax.jms.version}</version>
       <scope>compile</scope>
   </dependency>
   <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-jms</artifactId>
       <scope>compile</scope>
   </dependency>
   <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-beans</artifactId>
       <scope>compile</scope>
   </dependency>
</dependencies>
    
<build>
   <plugins>
       <plugin>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-maven-plugin</artifactId>
           <configuration>
               <mainClass>gov.va.dgi.DgiJavaInstitutionManagerServiceApplication</mainClass>
           </configuration>
       </plugin>
       <plugin>
           <groupId>org.codehaus.mojo</groupId>
           <artifactId>build-helper-maven-plugin</artifactId>
           <version>${build.helper.maven.plugin.version}</version>
           <executions>
               <execution>
                   <id>add-integration-test-source</id>
                   <phase>generate-test-sources</phase>
                   <goals>
                       <goal>add-test-source</goal>
                   </goals>
                   <configuration>
                       <sources>
                           <source>src/integration-test/java</source>
                       </sources>
                   </configuration>
               </execution>
           </executions>
       </plugin>
       <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-surefire-plugin</artifactId>
           <version>${maven.surefire.plugin.version}</version>
           <configuration>
               <skipTests>false</skipTests>
               <excludes>
                   <exclude>**/*IntegrationTest</exclude>
                   <exclude>**/*IT</exclude>
               </excludes>
           </configuration>
       </plugin>
   </plugins>
</build>

<profiles>
   <profile>
       <id>failsafe</id>
       <build>
           <testResources>
               <testResource>
                   <directory>src/integration-test/resources</directory>
               </testResource>
           </testResources>
           <plugins>
<!-- when running failsafe integration tests, we do not want to run regular unit tests-->
               <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-surefire-plugin</artifactId>
                   <version>${maven.surefire.plugin.version}</version>
                   <configuration>
                       <skipTests>true</skipTests>
                       <excludes>
                           <exclude>**/*IntegrationTest</exclude>
                           <exclude>**/*IT</exclude>
                       </excludes>
                   </configuration>
               </plugin>
    
               <plugin>
                   <artifactId>maven-failsafe-plugin</artifactId>
                   <version>${maven.failsafe.plugin.version}</version>
                   <executions>
                       <execution>
                           <goals>
                               <goal>integration-test</goal>
                               <goal>verify</goal>
                           </goals>
                       </execution>
                   </executions>
                   <configuration>
 <!-- for int tests, remove H2 so @SpringBootTest and @DataJpaTests don't switch the db -->
                       <classpathDependencyExcludes>
                                 <classpathDependencyExclude>com.h2database:h2</classpathDependencyExclude>
                       </classpathDependencyExcludes>
                   </configuration>
               </plugin>
           </plugins>
        </build>
     </profile>
   </profiles>
    
 </project>
1 Answers
Related