diff --git a/.gitattributes b/.gitattributes index 21256661..176a458f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -* text=auto \ No newline at end of file +* text=auto diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 2d3f621b..00000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright 2010-2020 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 -# -# http://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. -# - -version: 2 -updates: -- package-ecosystem: maven - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 - labels: - - dependencies - ignore: - - dependency-name: org.apache.tomcat:tomcat - versions: - - "> 9.1.0" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b09f468c..4fe1235a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,41 +1,29 @@ -# -# Copyright 2015-2020 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 -# -# http://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. -# - name: Java CI -on: [push, pull_request] +on: [workflow_dispatch, push, pull_request] + +permissions: read-all jobs: test: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] - java: [8, 11, 17, 18-ea] - distribution: ['zulu'] + cache: [maven] + distribution: [temurin] + java: [17, 21, 24, 25-ea] + os: [ubuntu-latest, macos-latest, windows-latest] fail-fast: false max-parallel: 4 name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Set up JDK - uses: actions/setup-java@v2 + - uses: actions/checkout@v5 + - name: Set up JDK ${{ matrix.java }} ${{ matrix.distribution }} + uses: actions/setup-java@v5 with: java-version: ${{ matrix.java }} distribution: ${{ matrix.distribution }} + cache: ${{ matrix.cache }} - name: Test with Maven - run: ./mvnw test -B -D"license.skip=true" + run: ./mvnw test -B -V --no-transfer-progress -D"license.skip=true" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..172c20ac --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,49 @@ +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + schedule: + - cron: '45 13 * * 3' + +jobs: + analyze: + name: Analyze + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'java-kotlin' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Setup Java + uses: actions/setup-java@v5 + with: + cache: maven + distribution: 'temurin' + java-version: 21 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v4 + with: + languages: ${{ matrix.language }} + queries: +security-and-quality + + - name: Autobuild + uses: github/codeql-action/autobuild@v4 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v4 + with: + category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index 93000293..09ab9b4a 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -1,42 +1,29 @@ -# -# Copyright 2015-2020 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 -# -# http://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. -# - name: Coveralls on: [push, pull_request] +permissions: read-all + jobs: build: if: github.repository_owner == 'mybatis' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v5 - name: Set up JDK - uses: actions/setup-java@v2 + uses: actions/setup-java@v5 with: - java-version: 11 - distribution: zulu + cache: maven + distribution: temurin + java-version: 21 - name: Report Coverage to Coveralls for Pull Requests if: github.event_name == 'pull_request' - run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER + run: ./mvnw -B -V test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER --no-transfer-progress env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.number }} - name: Report Coverage to Coveralls for General Push if: github.event_name == 'push' - run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github + run: ./mvnw -B -V test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github --no-transfer-progress env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml new file mode 100644 index 00000000..9942e712 --- /dev/null +++ b/.github/workflows/site.yaml @@ -0,0 +1,32 @@ +name: Site + +on: + push: + branches: + - site + +permissions: + contents: write + +jobs: + build: + if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Set up JDK + uses: actions/setup-java@v5 + with: + cache: maven + distribution: temurin + java-version: 21 + - name: Build site + run: ./mvnw site site:stage -DskipTests -Dlicense.skip=true -B -V --no-transfer-progress --settings ./.mvn/settings.xml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NVD_API_KEY: ${{ secrets.NVD_API_KEY }} + - name: Deploy Site to gh-pages + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages + folder: target/spring-boot-starter.git diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index ca4aa2a5..d2af8944 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -1,19 +1,3 @@ -# -# Copyright 2015-2020 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 -# -# http://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. -# - name: SonarCloud on: @@ -21,22 +5,25 @@ on: branches: - master +permissions: read-all + jobs: build: if: github.repository_owner == 'mybatis' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v5 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 - name: Set up JDK - uses: actions/setup-java@v2 + uses: actions/setup-java@v5 with: - java-version: 11 - distribution: zulu + cache: maven + distribution: temurin + java-version: 21 - name: Analyze with SonarCloud - run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_spring-boot-starter -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true + run: ./mvnw verify jacoco:report sonar:sonar -B -V -Dsonar.projectKey=mybatis_spring-boot-starter -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.token=$SONAR_TOKEN -Dlicense.skip=true --no-transfer-progress env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index 10fb6562..9f47d203 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -1,19 +1,3 @@ -# -# Copyright 2015-2020 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 -# -# http://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. -# - name: Sonatype on: @@ -21,19 +5,22 @@ on: branches: - master +permissions: read-all + jobs: build: if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v5 - name: Set up JDK - uses: actions/setup-java@v2 + uses: actions/setup-java@v5 with: - java-version: 11 - distribution: zulu + cache: maven + distribution: temurin + java-version: 21 - name: Deploy to Sonatype - run: ./mvnw deploy -DskipTests -B --settings ./.mvn/settings.xml -Dlicense.skip=true + run: ./mvnw deploy -DskipTests -B -V --no-transfer-progress --settings ./.mvn/settings.xml -Dlicense.skip=true env: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} diff --git a/.github/workflows/support.yaml b/.github/workflows/support.yaml index 15959eef..80869eaf 100644 --- a/.github/workflows/support.yaml +++ b/.github/workflows/support.yaml @@ -1,5 +1,5 @@ # -# Copyright 2010-2020 the original author or authors. +# Copyright 2015-2023 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. @@ -18,26 +18,28 @@ name: Spring Boot Support Samples on: [push, pull_request] +permissions: read-all + jobs: test: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macOS-latest] - java: [8, 11, 17, 18-ea] + os: [ubuntu-latest, macOS-latest, windows-latest] + java: [17, 21] distribution: ['zulu'] fail-fast: false - max-parallel: 4 + max-parallel: 5 name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v5 - name: Set up JDK - uses: actions/setup-java@v2 + uses: actions/setup-java@v5 with: java-version: ${{ matrix.java }} distribution: ${{ matrix.distribution }} - name: Test with Spring Boot Latest run: | - ./mvnw test + ./mvnw package ./mybatis-spring-boot-samples/run_fatjars.sh diff --git a/.gitignore b/.gitignore index e4baae24..d90054c2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ target/ .factorypath .mvn/wrapper/maven-wrapper.jar +*.releaseBackup +release.properties +.github/keys/ diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index dcadaccd..4b143af9 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -1,13 +1,13 @@ - + + + - ossrh + central ${env.CI_DEPLOY_USERNAME} ${env.CI_DEPLOY_PASSWORD} + + - gh-pages + gh-pages-scm + + branch + gh-pages + + + github - ${env.CI_DEPLOY_USERNAME} ${env.GITHUB_TOKEN} + + + + nvd + ${env.NVD_API_KEY} + + diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 00000000..bdf0ddfa --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +import java.io.IOException; +import java.io.InputStream; +import java.net.Authenticator; +import java.net.PasswordAuthentication; +import java.net.URI; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.concurrent.ThreadLocalRandom; + +public final class MavenWrapperDownloader { + private static final String WRAPPER_VERSION = "3.3.2"; + + private static final boolean VERBOSE = Boolean.parseBoolean(System.getenv("MVNW_VERBOSE")); + + public static void main(String[] args) { + log("Apache Maven Wrapper Downloader " + WRAPPER_VERSION); + + if (args.length != 2) { + System.err.println(" - ERROR wrapperUrl or wrapperJarPath parameter missing"); + System.exit(1); + } + + try { + log(" - Downloader started"); + final URL wrapperUrl = URI.create(args[0]).toURL(); + final String jarPath = args[1].replace("..", ""); // Sanitize path + final Path wrapperJarPath = Paths.get(jarPath).toAbsolutePath().normalize(); + downloadFileFromURL(wrapperUrl, wrapperJarPath); + log("Done"); + } catch (IOException e) { + System.err.println("- Error downloading: " + e.getMessage()); + if (VERBOSE) { + e.printStackTrace(); + } + System.exit(1); + } + } + + private static void downloadFileFromURL(URL wrapperUrl, Path wrapperJarPath) + throws IOException { + log(" - Downloading to: " + wrapperJarPath); + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + final String username = System.getenv("MVNW_USERNAME"); + final char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + Path temp = wrapperJarPath + .getParent() + .resolve(wrapperJarPath.getFileName() + "." + + Long.toUnsignedString(ThreadLocalRandom.current().nextLong()) + ".tmp"); + try (InputStream inStream = wrapperUrl.openStream()) { + Files.copy(inStream, temp, StandardCopyOption.REPLACE_EXISTING); + Files.move(temp, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING); + } finally { + Files.deleteIfExists(temp); + } + log(" - Downloader complete"); + } + + private static void log(String msg) { + if (VERBOSE) { + System.out.println(msg); + } + } + +} diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 8c79a83a..b06697c6 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -5,14 +5,16 @@ # to you 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# +# +# 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. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar +wrapperVersion=3.3.2 +distributionType=source +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar diff --git a/LICENSE b/LICENSE index 8f71f43f..7e835b2f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ Apache License Version 2.0, January 2004 - http://www.apache.org/licenses/ + https://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION @@ -178,7 +178,7 @@ APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" + boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a @@ -186,13 +186,13 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright {yyyy} {name of copyright owner} + Copyright [yyyy] [name of copyright owner] 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 - http://www.apache.org/licenses/LICENSE-2.0 + 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/license.txt b/LICENSE_HEADER similarity index 92% rename from mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/license.txt rename to LICENSE_HEADER index 4ce1777a..a81590a5 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/license.txt +++ b/LICENSE_HEADER @@ -4,7 +4,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + 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, diff --git a/NOTICE b/NOTICE new file mode 100644 index 00000000..c9a4eae6 --- /dev/null +++ b/NOTICE @@ -0,0 +1,5 @@ +MyBatis Spring Boot +Copyright 2015-2023 + +This product includes software developed by +The MyBatis Team (https://www.mybatis.org/). diff --git a/README.md b/README.md index 5e3e3d8e..8d79e2fe 100644 --- a/README.md +++ b/README.md @@ -4,22 +4,24 @@ [![Coverage Status](https://coveralls.io/repos/github/mybatis/spring-boot-starter/badge.svg?branch=master)](https://coveralls.io/github/mybatis/spring-boot-starter?branch=master) [![Maven central](https://maven-badges.herokuapp.com/maven-central/org.mybatis.spring.boot/mybatis-spring-boot/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mybatis.spring.boot/mybatis-spring-boot) [![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.mybatis.spring.boot/mybatis-spring-boot.svg)](https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/spring/boot/mybatis-spring-boot/) -[![License](http://img.shields.io/:license-apache-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) +[![License](https://img.shields.io/:license-apache-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) -![mybatis-spring](http://mybatis.github.io/images/mybatis-logo.png) +![mybatis-spring](https://mybatis.org/images/mybatis-logo.png) -MyBatis Spring-Boot-Starter will help you to use MyBatis with Spring Boot +MyBatis Spring-Boot-Starter will help you to use [MyBatis](https://github.com/mybatis/mybatis-3) with [Spring Boot](https://github.com/spring-projects/spring-boot) ## Requirements -* master(2.2.x) : MyBatis 3.5+, MyBatis-Spring 2.0+(2.0.6+ recommended), Java 8+ and Spring Boot 2.5+ -* 2.1.x : MyBatis 3.5+, MyBatis-Spring 2.0+(2.0.6+ recommended), Java 8+ and Spring Boot 2.1-2.4 -* ~~2.0.x : (EOL) MyBatis 3.5+, MyBatis-Spring 2.0+, Java 8+ and Spring Boot 2.0/2.1.~~ -* ~~1.3.x : (EOL) MyBatis 3.4+, MyBatis-Spring 1.3+, Java 6+ and Spring Boot 1.5~~ +* master : MyBatis 3.5, MyBatis-Spring 3.0, Java 17+ and Spring Boot 3.0-3.5 +* 2.3.x : MyBatis 3.5, MyBatis-Spring 2.1, Java 8+ and Spring Boot 2.7 ## Compatibility Check -* Compatibility with Spring Boot 2.3 - 2.6 latest version [here](https://github.com/kazuki43zoo/mybatis-spring-boot-dev-compatibility-checker) +* Compatibility with Spring Boot 2.7 - 3.5 [here](https://github.com/kazuki43zoo/mybatis-spring-boot-dev-compatibility-checker) + +## Creating new project via Spring Initializr + +* https://start.spring.io/#!dependencies=mybatis ## Essentials @@ -33,10 +35,20 @@ MyBatis Spring-Boot-Starter will help you to use MyBatis with Spring Boot * [See the docs](https://github.com/mybatis/spring-boot-starter/blob/master/mybatis-spring-boot-autoconfigure/src/site/markdown/index.md) * [See the docs for testing](https://github.com/mybatis/spring-boot-starter/blob/master/mybatis-spring-boot-test-autoconfigure/src/site/markdown/index.md) +Translations: + +* [See the docs(简体中文)](https://github.com/mybatis/spring-boot-starter/blob/master/mybatis-spring-boot-autoconfigure/src/site/zh_CN/markdown/index.md) +* [See the docs for testing(简体中文)](https://github.com/mybatis/spring-boot-starter/blob/master/mybatis-spring-boot-test-autoconfigure/src/site/zh_CN/markdown/index.md) + + ## Quick Start * [See the wiki page](https://github.com/mybatis/spring-boot-starter/wiki/Quick-Start) +## Quick Start for building native image + +* [See the wiki page](https://github.com/mybatis/spring-boot-starter/wiki/Quick-Start-for-building-native-image) + ## Bug report & Feature request * [GitHub Issue Tracker](https://github.com/mybatis/spring-boot-starter/issues) diff --git a/format.xml b/format.xml index 3d9292c7..6d9e588e 100644 --- a/format.xml +++ b/format.xml @@ -1,13 +1,13 @@ - + 4.0.0 org.mybatis.spring.boot mybatis-spring-boot - 2.2.3-SNAPSHOT + 3.0.6-SNAPSHOT mybatis-spring-boot-autoconfigure mybatis-spring-boot-autoconfigure @@ -92,7 +92,7 @@ spring-boot-configuration-processor true - + com.h2database @@ -109,6 +109,16 @@ spring-boot-starter-test test + + org.flywaydb + flyway-core + test + + + org.liquibase + liquibase-core + test + diff --git a/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/ConfigurationCustomizer.java b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/ConfigurationCustomizer.java index da4fd5d7..350705a8 100644 --- a/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/ConfigurationCustomizer.java +++ b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/ConfigurationCustomizer.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -21,6 +21,7 @@ * Callback interface that can be customized a {@link Configuration} object generated on auto-configuration. * * @author Kazuki Shimizu + * * @since 1.2.1 */ @FunctionalInterface diff --git a/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.java b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.java index 7dca1a74..5da820fa 100644 --- a/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.java +++ b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2022 the original author or authors. + * Copyright 2015-2025 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -71,18 +71,16 @@ /** * {@link EnableAutoConfiguration Auto-Configuration} for Mybatis. Contributes a {@link SqlSessionFactory} and a - * {@link SqlSessionTemplate}. - * - * If {@link org.mybatis.spring.annotation.MapperScan} is used, or a configuration file is specified as a property, - * those will be considered, otherwise this auto-configuration will attempt to register mappers based on the interface - * definitions in or under the root auto-configuration package. + * {@link SqlSessionTemplate}. If {@link org.mybatis.spring.annotation.MapperScan} is used, or a configuration file is + * specified as a property, those will be considered, otherwise this auto-configuration will attempt to register mappers + * based on the interface definitions in or under the root auto-configuration package. * * @author Eddú Meléndez * @author Josh Long * @author Kazuki Shimizu * @author Eduardo Macarrón */ -@org.springframework.context.annotation.Configuration +@org.springframework.context.annotation.Configuration(proxyBeanMethods = false) @ConditionalOnClass({ SqlSessionFactory.class, SqlSessionFactoryBean.class }) @ConditionalOnSingleCandidate(DataSource.class) @EnableConfigurationProperties(MybatisProperties.class) @@ -140,7 +138,9 @@ private void checkConfigFileExists() { public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { SqlSessionFactoryBean factory = new SqlSessionFactoryBean(); factory.setDataSource(dataSource); - factory.setVfs(SpringBootVFS.class); + if (properties.getConfiguration() == null || properties.getConfiguration().getVfsImpl() == null) { + factory.setVfs(SpringBootVFS.class); + } if (StringUtils.hasText(this.properties.getConfigLocation())) { factory.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation())); } @@ -166,8 +166,9 @@ public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Excepti if (!ObjectUtils.isEmpty(this.typeHandlers)) { factory.setTypeHandlers(this.typeHandlers); } - if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) { - factory.setMapperLocations(this.properties.resolveMapperLocations()); + Resource[] mapperLocations = this.properties.resolveMapperLocations(); + if (!ObjectUtils.isEmpty(mapperLocations)) { + factory.setMapperLocations(mapperLocations); } Set factoryPropertyNames = Stream .of(new BeanWrapperImpl(SqlSessionFactoryBean.class).getPropertyDescriptors()).map(PropertyDescriptor::getName) @@ -189,10 +190,14 @@ public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Excepti } private void applyConfiguration(SqlSessionFactoryBean factory) { - Configuration configuration = this.properties.getConfiguration(); - if (configuration == null && !StringUtils.hasText(this.properties.getConfigLocation())) { + MybatisProperties.CoreConfiguration coreConfiguration = this.properties.getConfiguration(); + Configuration configuration = null; + if (coreConfiguration != null || !StringUtils.hasText(this.properties.getConfigLocation())) { configuration = new Configuration(); } + if (configuration != null && coreConfiguration != null) { + coreConfiguration.applyTo(configuration); + } if (configuration != null && !CollectionUtils.isEmpty(this.configurationCustomizers)) { for (ConfigurationCustomizer customizer : this.configurationCustomizers) { customizer.customize(configuration); @@ -275,7 +280,7 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, B builder.addPropertyValue("sqlSessionTemplateBeanName", sqlSessionTemplateBeanName.orElse("sqlSessionTemplate")); } else { - builder.addPropertyValue("sqlSessionFactoryBeanName", sqlSessionFactoryBeanName.get()); + builder.addPropertyValue("sqlSessionFactoryBeanName", sqlSessionFactoryBeanName.orElseThrow()); } } builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); @@ -304,7 +309,7 @@ private String getBeanNameForType(Class type, ListableBeanFactory factory) { * If mapper registering configuration or mapper scanning configuration not present, this configuration allow to scan * mappers based on the same component-scanning path as Spring Boot itself. */ - @org.springframework.context.annotation.Configuration + @org.springframework.context.annotation.Configuration(proxyBeanMethods = false) @Import(AutoConfiguredMapperScannerRegistrar.class) @ConditionalOnMissingBean({ MapperFactoryBean.class, MapperScannerConfigurer.class }) public static class MapperScannerRegistrarNotFoundConfiguration implements InitializingBean { diff --git a/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisDependsOnDatabaseInitializationDetector.java b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisDependsOnDatabaseInitializationDetector.java new file mode 100644 index 00000000..a9c83b73 --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisDependsOnDatabaseInitializationDetector.java @@ -0,0 +1,40 @@ +/* + * Copyright 2015-2022 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.mybatis.spring.boot.autoconfigure; + +import java.util.Collections; +import java.util.Set; + +import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.boot.sql.init.dependency.AbstractBeansOfTypeDependsOnDatabaseInitializationDetector; +import org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector; + +/** + * {@link DependsOnDatabaseInitializationDetector} for Mybatis. + * + * @author Eddú Meléndez + * + * @since 2.3.0 + */ +class MybatisDependsOnDatabaseInitializationDetector + extends AbstractBeansOfTypeDependsOnDatabaseInitializationDetector { + + @Override + protected Set> getDependsOnDatabaseInitializationBeanTypes() { + return Collections.singleton(SqlSessionTemplate.class); + } + +} diff --git a/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisLanguageDriverAutoConfiguration.java b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisLanguageDriverAutoConfiguration.java index 91c7d948..3e6b2619 100644 --- a/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisLanguageDriverAutoConfiguration.java +++ b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisLanguageDriverAutoConfiguration.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -34,9 +34,10 @@ * {@link EnableAutoConfiguration Auto-Configuration} for MyBatis's scripting language drivers. * * @author Kazuki Shimizu + * * @since 2.1.0 */ -@Configuration +@Configuration(proxyBeanMethods = false) @ConditionalOnClass(LanguageDriver.class) public class MybatisLanguageDriverAutoConfiguration { @@ -45,7 +46,7 @@ public class MybatisLanguageDriverAutoConfiguration { /** * Configuration class for mybatis-freemarker 1.1.x or under. */ - @Configuration + @Configuration(proxyBeanMethods = false) @ConditionalOnClass(FreeMarkerLanguageDriver.class) @ConditionalOnMissingClass("org.mybatis.scripting.freemarker.FreeMarkerLanguageDriverConfig") public static class LegacyFreeMarkerConfiguration { @@ -59,7 +60,7 @@ FreeMarkerLanguageDriver freeMarkerLanguageDriver() { /** * Configuration class for mybatis-freemarker 1.2.x or above. */ - @Configuration + @Configuration(proxyBeanMethods = false) @ConditionalOnClass({ FreeMarkerLanguageDriver.class, FreeMarkerLanguageDriverConfig.class }) public static class FreeMarkerConfiguration { @Bean @@ -79,7 +80,7 @@ public FreeMarkerLanguageDriverConfig freeMarkerLanguageDriverConfig() { /** * Configuration class for mybatis-velocity 2.0 or under. */ - @Configuration + @Configuration(proxyBeanMethods = false) @ConditionalOnClass(org.mybatis.scripting.velocity.Driver.class) @ConditionalOnMissingClass("org.mybatis.scripting.velocity.VelocityLanguageDriverConfig") @SuppressWarnings("deprecation") @@ -94,7 +95,7 @@ org.mybatis.scripting.velocity.Driver velocityLanguageDriver() { /** * Configuration class for mybatis-velocity 2.1.x or above. */ - @Configuration + @Configuration(proxyBeanMethods = false) @ConditionalOnClass({ VelocityLanguageDriver.class, VelocityLanguageDriverConfig.class }) public static class VelocityConfiguration { @Bean @@ -111,7 +112,7 @@ public VelocityLanguageDriverConfig velocityLanguageDriverConfig() { } } - @Configuration + @Configuration(proxyBeanMethods = false) @ConditionalOnClass(ThymeleafLanguageDriver.class) public static class ThymeleafConfiguration { @Bean diff --git a/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisProperties.java b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisProperties.java index 8a3092b8..da6c4115 100644 --- a/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisProperties.java +++ b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/MybatisProperties.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2025 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -18,13 +18,23 @@ import java.io.IOException; import java.util.Optional; import java.util.Properties; +import java.util.Set; import java.util.stream.Stream; +import org.apache.ibatis.io.VFS; +import org.apache.ibatis.logging.Log; +import org.apache.ibatis.mapping.ResultSetType; import org.apache.ibatis.scripting.LanguageDriver; +import org.apache.ibatis.session.AutoMappingBehavior; +import org.apache.ibatis.session.AutoMappingUnknownColumnBehavior; import org.apache.ibatis.session.Configuration; import org.apache.ibatis.session.ExecutorType; +import org.apache.ibatis.session.LocalCacheScope; +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.TypeHandler; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.NestedConfigurationProperty; +import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; +import org.springframework.boot.context.properties.PropertyMapper; import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.ResourcePatternResolver; @@ -92,8 +102,7 @@ public class MybatisProperties { * A Configuration object for customize default settings. If {@link #configLocation} is specified, this property is * not used. */ - @NestedConfigurationProperty - private Configuration configuration; + private CoreConfiguration configuration; /** * @since 1.1.0 @@ -191,11 +200,11 @@ public void setConfigurationProperties(Properties configurationProperties) { this.configurationProperties = configurationProperties; } - public Configuration getConfiguration() { + public CoreConfiguration getConfiguration() { return configuration; } - public void setConfiguration(Configuration configuration) { + public void setConfiguration(CoreConfiguration configuration) { this.configuration = configuration; } @@ -212,4 +221,493 @@ private Resource[] getResources(String location) { } } + /** + * The configuration properties for mybatis core module. + * + * @since 3.0.0 + */ + public static class CoreConfiguration { + + /** + * Allows using RowBounds on nested statements. If allow, set the false. Default is false. + */ + private Boolean safeRowBoundsEnabled; + + /** + * Allows using ResultHandler on nested statements. If allow, set the false. Default is true. + */ + private Boolean safeResultHandlerEnabled; + + /** + * Enables automatic mapping from classic database column names A_COLUMN to camel case classic Java property names + * aColumn. Default is false. + */ + private Boolean mapUnderscoreToCamelCase; + + /** + * When enabled, any method call will load all the lazy properties of the object. Otherwise, each property is loaded + * on demand (see also lazyLoadTriggerMethods). Default is false. + */ + private Boolean aggressiveLazyLoading; + + /** + * Allows or disallows multiple ResultSets to be returned from a single statement (compatible driver required). + * Default is true. + */ + private Boolean multipleResultSetsEnabled; + + /** + * Allows JDBC support for generated keys. A compatible driver is required. This setting forces generated keys to be + * used if set to true, as some drivers deny compatibility but still work (e.g. Derby). Default is false. + */ + private Boolean useGeneratedKeys; + + /** + * Uses the column label instead of the column name. Different drivers behave differently in this respect. Refer to + * the driver documentation, or test out both modes to determine how your driver behaves. Default is true. + */ + private Boolean useColumnLabel; + + /** + * Globally enables or disables any caches configured in any mapper under this configuration. Default is true. + */ + private Boolean cacheEnabled; + + /** + * Specifies if setters or map's put method will be called when a retrieved value is null. It is useful when you + * rely on Map.keySet() or null value initialization. Note primitives such as (int,boolean,etc.) will not be set to + * null. Default is false. + */ + private Boolean callSettersOnNulls; + + /** + * Allow referencing statement parameters by their actual names declared in the method signature. To use this + * feature, your project must be compiled in Java 8 with -parameters option. Default is true. + */ + private Boolean useActualParamName; + + /** + * MyBatis, by default, returns null when all the columns of a returned row are NULL. When this setting is enabled, + * MyBatis returns an empty instance instead. Note that it is also applied to nested results (i.e. collection and + * association). Default is false. + */ + private Boolean returnInstanceForEmptyRow; + + /** + * Removes extra whitespace characters from the SQL. Note that this also affects literal strings in SQL. Default is + * false. + */ + private Boolean shrinkWhitespacesInSql; + + /** + * Specifies the default value of 'nullable' attribute on 'foreach' tag. Default is false. + */ + private Boolean nullableOnForEach; + + /** + * When applying constructor auto-mapping, argument name is used to search the column to map instead of relying on + * the column order. Default is false. + */ + private Boolean argNameBasedConstructorAutoMapping; + + /** + * Globally enables or disables lazy loading. When enabled, all relations will be lazily loaded. This value can be + * superseded for a specific relation by using the fetchType attribute on it. Default is False. + */ + private Boolean lazyLoadingEnabled; + + /** + * Sets the number of seconds the driver will wait for a response from the database. + */ + private Integer defaultStatementTimeout; + + /** + * Sets the driver a hint as to control fetching size for return results. This parameter value can be override by a + * query setting. + */ + private Integer defaultFetchSize; + + /** + * MyBatis uses local cache to prevent circular references and speed up repeated nested queries. By default + * (SESSION) all queries executed during a session are cached. If localCacheScope=STATEMENT local session will be + * used just for statement execution, no data will be shared between two different calls to the same SqlSession. + * Default is SESSION. + */ + private LocalCacheScope localCacheScope; + + /** + * Specifies the JDBC type for null values when no specific JDBC type was provided for the parameter. Some drivers + * require specifying the column JDBC type but others work with generic values like NULL, VARCHAR or OTHER. Default + * is OTHER. + */ + private JdbcType jdbcTypeForNull; + + /** + * Specifies a scroll strategy when omit it per statement settings. + */ + private ResultSetType defaultResultSetType; + + /** + * Configures the default executor. SIMPLE executor does nothing special. REUSE executor reuses prepared statements. + * BATCH executor reuses statements and batches updates. Default is SIMPLE. + */ + private ExecutorType defaultExecutorType; + + /** + * Specifies if and how MyBatis should automatically map columns to fields/properties. NONE disables auto-mapping. + * PARTIAL will only auto-map results with no nested result mappings defined inside. FULL will auto-map result + * mappings of any complexity (containing nested or otherwise). Default is PARTIAL. + */ + private AutoMappingBehavior autoMappingBehavior; + + /** + * Specify the behavior when detects an unknown column (or unknown property type) of automatic mapping target. + * Default is NONE. + */ + private AutoMappingUnknownColumnBehavior autoMappingUnknownColumnBehavior; + + /** + * Specifies the prefix string that MyBatis will add to the logger names. + */ + private String logPrefix; + + /** + * Specifies which Object's methods trigger a lazy load. Default is [equals,clone,hashCode,toString]. + */ + private Set lazyLoadTriggerMethods; + + /** + * Specifies which logging implementation MyBatis should use. If this setting is not present logging implementation + * will be autodiscovered. + */ + private Class logImpl; + + /** + * Specifies VFS implementations. + */ + private Class vfsImpl; + + /** + * Specifies an sql provider class that holds provider method. This class apply to the type(or value) attribute on + * sql provider annotation(e.g. @SelectProvider), when these attribute was omitted. + */ + private Class defaultSqlProviderType; + + /** + * Specifies the TypeHandler used by default for Enum. + */ + Class defaultEnumTypeHandler; + + /** + * Specifies the class that provides an instance of Configuration. The returned Configuration instance is used to + * load lazy properties of deserialized objects. This class must have a method with a signature static Configuration + * getConfiguration(). + */ + private Class configurationFactory; + + /** + * Specify any configuration variables. + */ + private Properties variables; + + /** + * Specifies the database identify value for switching query to use. + */ + private String databaseId; + + public Boolean getSafeRowBoundsEnabled() { + return safeRowBoundsEnabled; + } + + public void setSafeRowBoundsEnabled(Boolean safeRowBoundsEnabled) { + this.safeRowBoundsEnabled = safeRowBoundsEnabled; + } + + public Boolean getSafeResultHandlerEnabled() { + return safeResultHandlerEnabled; + } + + public void setSafeResultHandlerEnabled(Boolean safeResultHandlerEnabled) { + this.safeResultHandlerEnabled = safeResultHandlerEnabled; + } + + public Boolean getMapUnderscoreToCamelCase() { + return mapUnderscoreToCamelCase; + } + + public void setMapUnderscoreToCamelCase(Boolean mapUnderscoreToCamelCase) { + this.mapUnderscoreToCamelCase = mapUnderscoreToCamelCase; + } + + public Boolean getAggressiveLazyLoading() { + return aggressiveLazyLoading; + } + + public void setAggressiveLazyLoading(Boolean aggressiveLazyLoading) { + this.aggressiveLazyLoading = aggressiveLazyLoading; + } + + @DeprecatedConfigurationProperty(since = "3.0.4", reason = "The option is not used at MyBatis core module. It will be removed in the future. See https://github.com/mybatis/mybatis-3/pull/3238") + public Boolean getMultipleResultSetsEnabled() { + return multipleResultSetsEnabled; + } + + public void setMultipleResultSetsEnabled(Boolean multipleResultSetsEnabled) { + this.multipleResultSetsEnabled = multipleResultSetsEnabled; + } + + public Boolean getUseGeneratedKeys() { + return useGeneratedKeys; + } + + public void setUseGeneratedKeys(Boolean useGeneratedKeys) { + this.useGeneratedKeys = useGeneratedKeys; + } + + public Boolean getUseColumnLabel() { + return useColumnLabel; + } + + public void setUseColumnLabel(Boolean useColumnLabel) { + this.useColumnLabel = useColumnLabel; + } + + public Boolean getCacheEnabled() { + return cacheEnabled; + } + + public void setCacheEnabled(Boolean cacheEnabled) { + this.cacheEnabled = cacheEnabled; + } + + public Boolean getCallSettersOnNulls() { + return callSettersOnNulls; + } + + public void setCallSettersOnNulls(Boolean callSettersOnNulls) { + this.callSettersOnNulls = callSettersOnNulls; + } + + public Boolean getUseActualParamName() { + return useActualParamName; + } + + public void setUseActualParamName(Boolean useActualParamName) { + this.useActualParamName = useActualParamName; + } + + public Boolean getReturnInstanceForEmptyRow() { + return returnInstanceForEmptyRow; + } + + public void setReturnInstanceForEmptyRow(Boolean returnInstanceForEmptyRow) { + this.returnInstanceForEmptyRow = returnInstanceForEmptyRow; + } + + public Boolean getShrinkWhitespacesInSql() { + return shrinkWhitespacesInSql; + } + + public void setShrinkWhitespacesInSql(Boolean shrinkWhitespacesInSql) { + this.shrinkWhitespacesInSql = shrinkWhitespacesInSql; + } + + public Boolean getNullableOnForEach() { + return nullableOnForEach; + } + + public void setNullableOnForEach(Boolean nullableOnForEach) { + this.nullableOnForEach = nullableOnForEach; + } + + public Boolean getArgNameBasedConstructorAutoMapping() { + return argNameBasedConstructorAutoMapping; + } + + public void setArgNameBasedConstructorAutoMapping(Boolean argNameBasedConstructorAutoMapping) { + this.argNameBasedConstructorAutoMapping = argNameBasedConstructorAutoMapping; + } + + public String getLogPrefix() { + return logPrefix; + } + + public void setLogPrefix(String logPrefix) { + this.logPrefix = logPrefix; + } + + public Class getLogImpl() { + return logImpl; + } + + public void setLogImpl(Class logImpl) { + this.logImpl = logImpl; + } + + public Class getVfsImpl() { + return vfsImpl; + } + + public void setVfsImpl(Class vfsImpl) { + this.vfsImpl = vfsImpl; + } + + public Class getDefaultSqlProviderType() { + return defaultSqlProviderType; + } + + public void setDefaultSqlProviderType(Class defaultSqlProviderType) { + this.defaultSqlProviderType = defaultSqlProviderType; + } + + public LocalCacheScope getLocalCacheScope() { + return localCacheScope; + } + + public void setLocalCacheScope(LocalCacheScope localCacheScope) { + this.localCacheScope = localCacheScope; + } + + public JdbcType getJdbcTypeForNull() { + return jdbcTypeForNull; + } + + public void setJdbcTypeForNull(JdbcType jdbcTypeForNull) { + this.jdbcTypeForNull = jdbcTypeForNull; + } + + public Set getLazyLoadTriggerMethods() { + return lazyLoadTriggerMethods; + } + + public void setLazyLoadTriggerMethods(Set lazyLoadTriggerMethods) { + this.lazyLoadTriggerMethods = lazyLoadTriggerMethods; + } + + public Integer getDefaultStatementTimeout() { + return defaultStatementTimeout; + } + + public void setDefaultStatementTimeout(Integer defaultStatementTimeout) { + this.defaultStatementTimeout = defaultStatementTimeout; + } + + public Integer getDefaultFetchSize() { + return defaultFetchSize; + } + + public void setDefaultFetchSize(Integer defaultFetchSize) { + this.defaultFetchSize = defaultFetchSize; + } + + public ResultSetType getDefaultResultSetType() { + return defaultResultSetType; + } + + public void setDefaultResultSetType(ResultSetType defaultResultSetType) { + this.defaultResultSetType = defaultResultSetType; + } + + public ExecutorType getDefaultExecutorType() { + return defaultExecutorType; + } + + public void setDefaultExecutorType(ExecutorType defaultExecutorType) { + this.defaultExecutorType = defaultExecutorType; + } + + public AutoMappingBehavior getAutoMappingBehavior() { + return autoMappingBehavior; + } + + public void setAutoMappingBehavior(AutoMappingBehavior autoMappingBehavior) { + this.autoMappingBehavior = autoMappingBehavior; + } + + public AutoMappingUnknownColumnBehavior getAutoMappingUnknownColumnBehavior() { + return autoMappingUnknownColumnBehavior; + } + + public void setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior autoMappingUnknownColumnBehavior) { + this.autoMappingUnknownColumnBehavior = autoMappingUnknownColumnBehavior; + } + + public Properties getVariables() { + return variables; + } + + public void setVariables(Properties variables) { + this.variables = variables; + } + + public Boolean getLazyLoadingEnabled() { + return lazyLoadingEnabled; + } + + public void setLazyLoadingEnabled(Boolean lazyLoadingEnabled) { + this.lazyLoadingEnabled = lazyLoadingEnabled; + } + + public Class getConfigurationFactory() { + return configurationFactory; + } + + public void setConfigurationFactory(Class configurationFactory) { + this.configurationFactory = configurationFactory; + } + + public Class getDefaultEnumTypeHandler() { + return defaultEnumTypeHandler; + } + + public void setDefaultEnumTypeHandler(Class defaultEnumTypeHandler) { + this.defaultEnumTypeHandler = defaultEnumTypeHandler; + } + + public String getDatabaseId() { + return databaseId; + } + + public void setDatabaseId(String databaseId) { + this.databaseId = databaseId; + } + + public void applyTo(Configuration target) { + PropertyMapper mapper = PropertyMapper.get().alwaysApplyingWhenNonNull(); + mapper.from(getSafeRowBoundsEnabled()).to(target::setSafeRowBoundsEnabled); + mapper.from(getSafeResultHandlerEnabled()).to(target::setSafeResultHandlerEnabled); + mapper.from(getMapUnderscoreToCamelCase()).to(target::setMapUnderscoreToCamelCase); + mapper.from(getAggressiveLazyLoading()).to(target::setAggressiveLazyLoading); + mapper.from(getMultipleResultSetsEnabled()).to(target::setMultipleResultSetsEnabled); + mapper.from(getUseGeneratedKeys()).to(target::setUseGeneratedKeys); + mapper.from(getUseColumnLabel()).to(target::setUseColumnLabel); + mapper.from(getCacheEnabled()).to(target::setCacheEnabled); + mapper.from(getCallSettersOnNulls()).to(target::setCallSettersOnNulls); + mapper.from(getUseActualParamName()).to(target::setUseActualParamName); + mapper.from(getReturnInstanceForEmptyRow()).to(target::setReturnInstanceForEmptyRow); + mapper.from(getShrinkWhitespacesInSql()).to(target::setShrinkWhitespacesInSql); + mapper.from(getNullableOnForEach()).to(target::setNullableOnForEach); + mapper.from(getArgNameBasedConstructorAutoMapping()).to(target::setArgNameBasedConstructorAutoMapping); + mapper.from(getLazyLoadingEnabled()).to(target::setLazyLoadingEnabled); + mapper.from(getLogPrefix()).to(target::setLogPrefix); + mapper.from(getLazyLoadTriggerMethods()).to(target::setLazyLoadTriggerMethods); + mapper.from(getDefaultStatementTimeout()).to(target::setDefaultStatementTimeout); + mapper.from(getDefaultFetchSize()).to(target::setDefaultFetchSize); + mapper.from(getLocalCacheScope()).to(target::setLocalCacheScope); + mapper.from(getJdbcTypeForNull()).to(target::setJdbcTypeForNull); + mapper.from(getDefaultResultSetType()).to(target::setDefaultResultSetType); + mapper.from(getDefaultExecutorType()).to(target::setDefaultExecutorType); + mapper.from(getAutoMappingBehavior()).to(target::setAutoMappingBehavior); + mapper.from(getAutoMappingUnknownColumnBehavior()).to(target::setAutoMappingUnknownColumnBehavior); + mapper.from(getVariables()).to(target::setVariables); + mapper.from(getLogImpl()).to(target::setLogImpl); + mapper.from(getVfsImpl()).to(target::setVfsImpl); + mapper.from(getDefaultSqlProviderType()).to(target::setDefaultSqlProviderType); + mapper.from(getConfigurationFactory()).to(target::setConfigurationFactory); + mapper.from(getDefaultEnumTypeHandler()).to(target::setDefaultEnumTypeHandler); + mapper.from(getDatabaseId()).to(target::setDatabaseId); + } + + } + } diff --git a/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/SpringBootVFS.java b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/SpringBootVFS.java index 0c7e0c02..51ba40a0 100644 --- a/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/SpringBootVFS.java +++ b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/SpringBootVFS.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2023 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -18,7 +18,11 @@ import java.io.IOException; import java.io.UncheckedIOException; import java.net.URL; +import java.net.URLDecoder; +import java.nio.charset.Charset; +import java.text.Normalizer; import java.util.List; +import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -26,6 +30,7 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.ResourcePatternResolver; +import org.springframework.util.ClassUtils; /** * @author Hans Westerbeek @@ -34,10 +39,17 @@ */ public class SpringBootVFS extends VFS { + private static Charset urlDecodingCharset; + private static Supplier classLoaderSupplier; private final ResourcePatternResolver resourceResolver; + static { + setUrlDecodingCharset(Charset.defaultCharset()); + setClassLoaderSupplier(ClassUtils::getDefaultClassLoader); + } + public SpringBootVFS() { - this.resourceResolver = new PathMatchingResourcePatternResolver(getClass().getClassLoader()); + this.resourceResolver = new PathMatchingResourcePatternResolver(classLoaderSupplier.get()); } @Override @@ -47,18 +59,50 @@ public boolean isValid() { @Override protected List list(URL url, String path) throws IOException { - String urlString = url.toString(); + String urlString = URLDecoder.decode(url.toString(), urlDecodingCharset); String baseUrlString = urlString.endsWith("/") ? urlString : urlString.concat("/"); Resource[] resources = resourceResolver.getResources(baseUrlString + "**/*.class"); return Stream.of(resources).map(resource -> preserveSubpackageName(baseUrlString, resource, path)) .collect(Collectors.toList()); } + /** + * Set the charset for decoding an encoded URL string. + *

+ * Default is system default charset. + *

+ * + * @param charset + * the charset for decoding an encoded URL string + * + * @since 2.3.0 + */ + public static void setUrlDecodingCharset(Charset charset) { + urlDecodingCharset = charset; + } + + /** + * Set the supplier for providing {@link ClassLoader} to used. + *

+ * Default is a returned instance from {@link ClassUtils#getDefaultClassLoader()}. + *

+ * + * @param supplier + * the supplier for providing {@link ClassLoader} to used + * + * @since 3.0.2 + */ + public static void setClassLoaderSupplier(Supplier supplier) { + classLoaderSupplier = supplier; + } + private static String preserveSubpackageName(final String baseUrlString, final Resource resource, final String rootPath) { try { return rootPath + (rootPath.endsWith("/") ? "" : "/") - + resource.getURL().toString().substring(baseUrlString.length()); + + Normalizer + .normalize(URLDecoder.decode(resource.getURL().toString(), urlDecodingCharset), Normalizer.Form.NFC) + .substring(baseUrlString.length()); } catch (IOException e) { throw new UncheckedIOException(e); } diff --git a/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/SqlSessionFactoryBeanCustomizer.java b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/SqlSessionFactoryBeanCustomizer.java index 8cb7bf51..a632b1ed 100644 --- a/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/SqlSessionFactoryBeanCustomizer.java +++ b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/SqlSessionFactoryBeanCustomizer.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -21,6 +21,7 @@ * Callback interface that can be customized a {@link SqlSessionFactoryBean} object generated on auto-configuration. * * @author Kazuki Shimizu + * * @since 2.2.2 */ @FunctionalInterface diff --git a/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/package-info.java b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/package-info.java index f3fb0f5b..f9a4442a 100644 --- a/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/package-info.java +++ b/mybatis-spring-boot-autoconfigure/src/main/java/org/mybatis/spring/boot/autoconfigure/package-info.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/mybatis-spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 7ed71cd2..854dc3c3 100644 --- a/mybatis-spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/mybatis-spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -1,23 +1,5 @@ { "properties": [ - { - "sourceType": "org.apache.ibatis.session.Configuration", - "defaultValue": "org.apache.ibatis.scripting.xmltags.XMLLanguageDriver", - "name": "mybatis.configuration.default-scripting-language", - "description": "A default LanguageDriver class.", - "type": "java.lang.Class", - "deprecation": { - "reason": "Because when this configuration property is used, there is case that custom language driver cannot be registered correctly.", - "replacement": "mybatis.default-scripting-language-driver" - } - }, - { - "sourceType": "org.apache.ibatis.session.Configuration", - "defaultValue": "org.apache.ibatis.type.EnumTypeHandler", - "name": "mybatis.configuration.default-enum-type-handler", - "description": "A default TypeHandler class for Enum.", - "type": "java.lang.Class" - }, { "defaultValue": false, "name": "mybatis.lazy-initialization", @@ -44,6 +26,5 @@ "replacement": "mybatis.scripting-language-driver.velocity.velocity-settings.runtime.custom_directives" } } - ] } diff --git a/mybatis-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories b/mybatis-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories index c6c1b373..03d145ae 100644 --- a/mybatis-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories +++ b/mybatis-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories @@ -1,4 +1,19 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.mybatis.spring.boot.autoconfigure.MybatisLanguageDriverAutoConfiguration,\ -org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration +# +# Copyright 2015-2023 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. +# + +# Depends On Database Initialization Detectors +org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector=\ +org.mybatis.spring.boot.autoconfigure.MybatisDependsOnDatabaseInitializationDetector diff --git a/mybatis-spring-boot-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/mybatis-spring-boot-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..2fad2b7c --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1,2 @@ +org.mybatis.spring.boot.autoconfigure.MybatisLanguageDriverAutoConfiguration +org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration diff --git a/mybatis-spring-boot-autoconfigure/src/site/markdown/index.md b/mybatis-spring-boot-autoconfigure/src/site/markdown/index.md index b2597ac3..69f59213 100644 --- a/mybatis-spring-boot-autoconfigure/src/site/markdown/index.md +++ b/mybatis-spring-boot-autoconfigure/src/site/markdown/index.md @@ -1,5 +1,14 @@ # Introduction +## Translations + +Users can read about MyBatis-Spring-Boot-Starter in the following translations: + + + ## What is MyBatis-Spring-Boot-Starter? The MyBatis-Spring-Boot-Starter help you build quickly MyBatis applications on top of the [Spring Boot](https://spring.io/projects/spring-boot). @@ -14,15 +23,17 @@ By using this module you will achieve: The MyBatis-Spring-Boot-Starter requires following versions: -| MyBatis-Spring-Boot-Starter | MyBatis-Spring | Spring Boot | Java | -| --- | --- | --- | --- | -| **2.2** | 2.0 (need 2.0.6+ for enable all features) | 2.5 or higher | 8 or higher | -| **2.1** | 2.0 (need 2.0.6+ for enable all features) | 2.1 - 2.4 | 8 or higher | -| **~~2.0 (EOL)~~** | ~~2.0~~ | ~~2.0 or 2.1~~ | ~~8 or higher~~ | -| **~~1.3 (EOL)~~** | ~~1.3~~ | ~~1.5~~ | ~~6 or higher~~ | -| **~~1.2 (EOL)~~** | ~~1.3~~ | ~~1.4~~ | ~~6 or higher~~ | -| **~~1.1 (EOL)~~** | ~~1.3~~ | ~~1.3~~ | ~~6 or higher~~ | -| **~~1.0 (EOL)~~** | ~~1.2~~ | ~~1.3~~ | ~~6 or higher~~ | +| MyBatis-Spring-Boot-Starter | MyBatis-Spring | Spring Boot | Java | +|-----------------------------|-------------------------------------------|----------------|-----------------| +| **3.0** | 3.0 | 3.0 - 3.5 | 17 or higher | +| **2.3** | 2.1 | 2.7 | 8 or higher | +| **~~2.2 (EOL)~~** | ~~2.0 (need 2.0.6+ for enable all features)~~ | ~~2.5 - 2.7~~ | ~~8 or higher~~ | +| **~~2.1 (EOL)~~** | ~~2.0 (need 2.0.6+ for enable all features)~~ | ~~2.1 - 2.4~~ | ~~8 or higher~~ | +| **~~2.0 (EOL)~~** | ~~2.0~~ | ~~2.0 or 2.1~~ | ~~8 or higher~~ | +| **~~1.3 (EOL)~~** | ~~1.3~~ | ~~1.5~~ | ~~6 or higher~~ | +| **~~1.2 (EOL)~~** | ~~1.3~~ | ~~1.4~~ | ~~6 or higher~~ | +| **~~1.1 (EOL)~~** | ~~1.3~~ | ~~1.3~~ | ~~6 or higher~~ | +| **~~1.0 (EOL)~~** | ~~1.2~~ | ~~1.3~~ | ~~6 or higher~~ | ## Installation @@ -46,7 +57,7 @@ If using gradle add this to your `build.gradle`: ```groovy dependencies { - compile("org.mybatis.spring.boot:mybatis-spring-boot-starter:${project.version}") + implementation("org.mybatis.spring.boot:mybatis-spring-boot-starter:${project.version}") } ``` @@ -283,7 +294,7 @@ public class MyBatisConfig { properties.put("H2", "h2"); databaseIdProvider.setProperties(properties); return databaseIdProvider; - } + } } ``` diff --git a/mybatis-spring-boot-autoconfigure/src/site/resources/css/site.css b/mybatis-spring-boot-autoconfigure/src/site/resources/css/site.css new file mode 100644 index 00000000..14a9eebc --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/site/resources/css/site.css @@ -0,0 +1,29 @@ +/** + * Copyright 2015-2023 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. + */ +/* + * when new flags are needed, take them from + * + * https://www.printableworldflags.com/flag-icon + * + * that are free for any kind of usage + */ + +ul.i18n {list-style-type:none;} +li.en {background: url('../images/en.png') left no-repeat;padding-left: 32px; margin: 10px} +li.es {background: url('../images/es.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ja {background: url('../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px} +li.zh {background: url('../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ko {background: url('../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px} diff --git a/mybatis-spring-boot-autoconfigure/src/site/resources/es/css/site.css b/mybatis-spring-boot-autoconfigure/src/site/resources/es/css/site.css new file mode 100644 index 00000000..804cd2bb --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/site/resources/es/css/site.css @@ -0,0 +1,29 @@ +/** + * Copyright 2015-2023 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. + */ +/* + * when new flags are needed, take them from + * + * https://www.printableworldflags.com/flag-icon + * + * that are free for any kind of usage + */ + +ul.i18n {list-style-type:none;} +li.en {background: url('../../images/en.png') left no-repeat;padding-left: 32px; margin: 10px} +li.es {background: url('../../images/es.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ja {background: url('../../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px} +li.zh {background: url('../../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ko {background: url('../../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px} diff --git a/mybatis-spring-boot-autoconfigure/src/site/resources/images/en.png b/mybatis-spring-boot-autoconfigure/src/site/resources/images/en.png new file mode 100644 index 00000000..82cf5f1c Binary files /dev/null and b/mybatis-spring-boot-autoconfigure/src/site/resources/images/en.png differ diff --git a/mybatis-spring-boot-autoconfigure/src/site/resources/images/es.png b/mybatis-spring-boot-autoconfigure/src/site/resources/images/es.png new file mode 100644 index 00000000..a4177e9f Binary files /dev/null and b/mybatis-spring-boot-autoconfigure/src/site/resources/images/es.png differ diff --git a/mybatis-spring-boot-autoconfigure/src/site/resources/images/ja.png b/mybatis-spring-boot-autoconfigure/src/site/resources/images/ja.png new file mode 100644 index 00000000..67020dfc Binary files /dev/null and b/mybatis-spring-boot-autoconfigure/src/site/resources/images/ja.png differ diff --git a/mybatis-spring-boot-autoconfigure/src/site/resources/images/ko.png b/mybatis-spring-boot-autoconfigure/src/site/resources/images/ko.png new file mode 100644 index 00000000..0e3d7062 Binary files /dev/null and b/mybatis-spring-boot-autoconfigure/src/site/resources/images/ko.png differ diff --git a/mybatis-spring-boot-autoconfigure/src/site/resources/images/zh.png b/mybatis-spring-boot-autoconfigure/src/site/resources/images/zh.png new file mode 100644 index 00000000..86ac698b Binary files /dev/null and b/mybatis-spring-boot-autoconfigure/src/site/resources/images/zh.png differ diff --git a/mybatis-spring-boot-autoconfigure/src/site/resources/ja/css/site.css b/mybatis-spring-boot-autoconfigure/src/site/resources/ja/css/site.css new file mode 100644 index 00000000..804cd2bb --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/site/resources/ja/css/site.css @@ -0,0 +1,29 @@ +/** + * Copyright 2015-2023 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. + */ +/* + * when new flags are needed, take them from + * + * https://www.printableworldflags.com/flag-icon + * + * that are free for any kind of usage + */ + +ul.i18n {list-style-type:none;} +li.en {background: url('../../images/en.png') left no-repeat;padding-left: 32px; margin: 10px} +li.es {background: url('../../images/es.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ja {background: url('../../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px} +li.zh {background: url('../../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ko {background: url('../../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px} diff --git a/mybatis-spring-boot-autoconfigure/src/site/resources/ko/css/site.css b/mybatis-spring-boot-autoconfigure/src/site/resources/ko/css/site.css new file mode 100644 index 00000000..804cd2bb --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/site/resources/ko/css/site.css @@ -0,0 +1,29 @@ +/** + * Copyright 2015-2023 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. + */ +/* + * when new flags are needed, take them from + * + * https://www.printableworldflags.com/flag-icon + * + * that are free for any kind of usage + */ + +ul.i18n {list-style-type:none;} +li.en {background: url('../../images/en.png') left no-repeat;padding-left: 32px; margin: 10px} +li.es {background: url('../../images/es.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ja {background: url('../../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px} +li.zh {background: url('../../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ko {background: url('../../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px} diff --git a/mybatis-spring-boot-autoconfigure/src/site/resources/zh_CN/css/site.css b/mybatis-spring-boot-autoconfigure/src/site/resources/zh_CN/css/site.css new file mode 100644 index 00000000..804cd2bb --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/site/resources/zh_CN/css/site.css @@ -0,0 +1,29 @@ +/** + * Copyright 2015-2023 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. + */ +/* + * when new flags are needed, take them from + * + * https://www.printableworldflags.com/flag-icon + * + * that are free for any kind of usage + */ + +ul.i18n {list-style-type:none;} +li.en {background: url('../../images/en.png') left no-repeat;padding-left: 32px; margin: 10px} +li.es {background: url('../../images/es.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ja {background: url('../../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px} +li.zh {background: url('../../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ko {background: url('../../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px} diff --git a/mybatis-spring-boot-autoconfigure/src/site/site.xml b/mybatis-spring-boot-autoconfigure/src/site/site.xml index 81476ced..de229266 100644 --- a/mybatis-spring-boot-autoconfigure/src/site/site.xml +++ b/mybatis-spring-boot-autoconfigure/src/site/site.xml @@ -1,13 +1,13 @@ - + @@ -26,4 +26,4 @@ - + diff --git a/mybatis-spring-boot-autoconfigure/src/site/site_zh.xml b/mybatis-spring-boot-autoconfigure/src/site/site_zh.xml new file mode 100644 index 00000000..4b7300e6 --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/site/site_zh.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + diff --git a/mybatis-spring-boot-autoconfigure/src/site/zh_CN/markdown/index.md b/mybatis-spring-boot-autoconfigure/src/site/zh_CN/markdown/index.md new file mode 100644 index 00000000..531c7331 --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/site/zh_CN/markdown/index.md @@ -0,0 +1,360 @@ +# 简介 + +## 文档的翻译版本 + +可以阅读 MyBatis-Spring-Boot-Starter 文档的以下翻译版本: + + + +## 什么是 MyBatis-Spring-Boot-Starter? + +MyBatis-Spring-Boot-Starter 可以帮助你更快地在 [Spring Boot](https://spring.io/projects/spring-boot) 之上构建 MyBatis 应用。 + +你将通过使用这个模块实现以下目的: + +* 构建单体应用程序 +* 将几乎不需要样板配置 +* 使用更少的 XML 配置 + +## 要求 + +MyBatis-Spring-Boot-Starter 要求以下版本: + +| MyBatis-Spring-Boot-Starter | MyBatis-Spring | Spring Boot | Java | +|-----------------------------|----------------------|---------------|-----------| +| **3.0** | 3.0 | 3.0 - 3.4 | 17 或更高 | +| **2.3** | 2.1 | 2.7 | 8 或更高 | +| **~~2.2 (EOL)~~** | ~~2.0(2.0.6 以上可开启所有特性~~) | ~~2.5 - 2.7~~ | ~~8 或更高~~ | +| **~~2.1 (EOL)~~** | ~~2.0(2.0.6 以上可开启所有特性)~~ | ~~2.1 - 2.4~~ | ~~8 或更高~~ | +| **~~2.0 (EOL)~~** | ~~2.0~~ | ~~2.0 或 2.1~~ | ~~8 或更高~~ | +| **~~1.3 (EOL)~~** | ~~1.3~~ | ~~1.5~~ | ~~6 或更高~~ | +| **~~1.2 (EOL)~~** | ~~1.3~~ | ~~1.4~~ | ~~6 或更高~~ | +| **~~1.1 (EOL)~~** | ~~1.3~~ | ~~1.3~~ | ~~6 或更高~~ | +| **~~1.0 (EOL)~~** | ~~1.2~~ | ~~1.3~~ | ~~6 或更高~~ | + +## 安装 + +要使用 MyBatis-Spring-Boot-Starter 模块,你只需要将 `mybatis-spring-boot-autoconfigure.jar` 文件以及它的依赖( `mybatis.jar`, `mybatis-spring.jar` 等) 放在类路径下。 + +### Maven + +如果你使用 Maven,只需要在你的 `pom.xml` 添加以下依赖: + +```xml + + org.mybatis.spring.boot + mybatis-spring-boot-starter + ${project.version} + +``` + +### Gradle + +如果使用 gradle,请在你的 `build.gradle` 中加入以下内容: + +```groovy +dependencies { + implementation("org.mybatis.spring.boot:mybatis-spring-boot-starter:${project.version}") +} +``` + +## 快速开始 + +正如你已经知道的, 要与 Spring 一起使用 MyBatis,你至少需要一个 `SqlSessionFactory` 和一个 mapper 接口。 + +MyBatis-Spring-Boot-Starter 将会: + +* 自动探测存在的 `DataSource` +* 将使用 `SqlSessionFactoryBean` 创建并注册一个 `SqlSessionFactory` 的实例,并将探测到的 `DataSource` 作为数据源 +* 将创建并注册一个从 `SqlSessionFactory` 中得到的 `SqlSessionTemplate` 的实例 +* 自动扫描你的 mapper,将它们与 `SqlSessionTemplate` 相关联,并将它们注册到Spring 的环境(context)中去,这样它们就可以被注入到你的 bean 中 + +假设我们有下面的 mapper : + +```java +@Mapper +public interface CityMapper { + + @Select("SELECT * FROM CITY WHERE state = #{state}") + City findByState(@Param("state") String state); + +} +``` + +你只需要创建一个 Spring boot 应用,像下面这样,将 mapper 注入进去( Spring 4.3 以上可用)。 + +```java +@SpringBootApplication +public class SampleMybatisApplication implements CommandLineRunner { + + private final CityMapper cityMapper; + + public SampleMybatisApplication(CityMapper cityMapper) { + this.cityMapper = cityMapper; + } + + public static void main(String[] args) { + SpringApplication.run(SampleMybatisApplication.class, args); + } + + @Override + public void run(String... args) throws Exception { + System.out.println(this.cityMapper.findByState("CA")); + } + +} +``` + +这就是你需要做的所有事情了。 你的 Spring boot 应用可以正常运行了。 + +## “扫描”的进阶用法 + + MyBatis-Spring-Boot-Starter 将默认搜寻带有 `@Mapper` 注解的 mapper 接口。 + +你可能想指定一个自定义的注解或接口来扫描,如果那样的话,你就必须使用 `@MapperScan` 注解了。在 [MyBatis-Spring 参考页面](https://mybatis.org/spring/zh_CN/mappers.html#scan) 中查看更多信息。 + +如果 MyBatis-Spring-Boot-Starter 发现至少有一个 `SqlSessionFactoryBean` ,它将不会开始扫描。 所以如果你想停止扫描,你应该用 `@Bean` 方法明确注册你的 mapper。 + +## 使用 SqlSession + +一个 `SqlSessionTemplate` 的实例被创建并添加到 Spring 的环境中,因此你可以使用 MyBatis API,让它像下面一样被注入到你的 bean 中(Spring 4.3 以上可用)。 + +```java +@Component +public class CityDao { + + private final SqlSession sqlSession; + + public CityDao(SqlSession sqlSession) { + this.sqlSession = sqlSession; + } + + public City selectCityById(long id) { + return this.sqlSession.selectOne("selectCityById", id); + } + +} +``` + +## 配置 + +像其他的 Spring Boot 应用一样,配置参数在 `application.properties` (或 `application.yml` )。 + +MyBatis 在它的配置项中,使用 `mybatis` 作为前缀。 + +可用的配置项如下: + +| 配置项(properties) | 描述 | +|:---------------------------------------- |:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `config-location` | MyBatis XML 配置文件的路径。 | +| `check-config-location` | 指定是否对 MyBatis XML 配置文件的存在进行检查。 | +| `mapper-locations` | XML 映射文件的路径。 | +| `type-aliases-package` | 搜索类型别名的包名。(包使用的分隔符是 "`,; \t\n`") | +| `type-aliases-super-type` | 用于过滤类型别名的父类。如果没有指定,MyBatis会将所有从 `type-aliases-package` 搜索到的类作为类型别名处理。 | +| `type-handlers-package` | 搜索类型处理器的包名。(包使用的分隔符是 "`,; \t\n`") | +| `executor-type` | SQL 执行器类型: `SIMPLE`, `REUSE`, `BATCH` | +| `default-scripting-language-driver` | 默认的脚本语言驱动(模板引擎),此功能需要与 mybatis-spring 2.0.2 以上版本一起使用。 | +| `configuration-properties` | 可在外部配置的 MyBatis 配置项。指定的配置项可以被用作 MyBatis 配置文件和 Mapper 文件的占位符。更多细节 见 [MyBatis 参考页面](https://mybatis.org/mybatis-3/zh_CN/configuration.html#properties)。 | +| `lazy-initialization` | 是否启用 mapper bean 的延迟初始化。设置 `true` 以启用延迟初始化。此功能需要与 mybatis-spring 2.0.2 以上版本一起使用。 | +| `mapper-default-scope` | 通过自动配置扫描的 mapper 组件的默认作用域。该功能需要与 mybatis-spring 2.0.6 以上版本一起使用。 | +| `inject-sql-session-on-mapper-scan` | 设置是否注入 `SqlSessionTemplate` 或  `SqlSessionFactory` 组件 (如果你想回到 2.2.1 或之前的行为,请指定 `false` )。如果你和 spring-native 一起使用,应该设置为 `true` (默认)。 | +| `configuration.*` | MyBatis Core 提供的`Configuration` 组件的配置项。有关可用的内部配置项,请参阅[MyBatis 参考页面](http://www.mybatis.org/mybatis-3/zh_CN/configuration.html#settings)。注:此属性不能与 `config-location` 同时使用。 | +| `scripting-language-driver.thymeleaf.*` | MyBatis `ThymeleafLanguageDriverConfig` 组件的 properties keys。有关可用的内部配置项,请参阅 [MyBatis Thymeleaf 参考页面](http://www.mybatis.org/thymeleaf-scripting/user-guide.html#_configuration_properties)。 | +| `scripting-language-driver.freemarker.*` | MyBatis `FreemarkerLanguageDriverConfig` 组件的 properties keys。有关可用的内部配置项,请参阅 [MyBatis FreeMarker 参考页面](http://www.mybatis.org/freemarker-scripting/#Configuration)。这个特性需要与 mybatis-freemarker 1.2.0 以上版本一起使用。 | +| `scripting-language-driver.velocity.*` | MyBatis `VelocityLanguageDriverConfig` 组件的  properties keys。有关可用的内部属性,请参阅 [MyBatis Velocity 参考页面](http://www.mybatis.org/velocity-scripting/#Configuration)。这个特性需要与 mybatis-velocity 2.1.0 以上版本一起使用。 | + +例如: + +```properties +# application.properties +mybatis.type-aliases-package=com.example.domain.model +mybatis.type-handlers-package=com.example.typehandler +mybatis.configuration.map-underscore-to-camel-case=true +mybatis.configuration.default-fetch-size=100 +mybatis.configuration.default-statement-timeout=30 +... +``` + +```yaml +# application.yml +mybatis: + type-aliases-package: com.example.domain.model + type-handlers-package: com.example.typehandler + configuration: + map-underscore-to-camel-case: true + default-fetch-size: 100 + default-statement-timeout: 30 +... +``` + +## 使用 ConfigurationCustomizer + +MyBatis-Spring-Boot-Starter 提供了使用 Java Config 来自定义 MyBatis 配置的可能。 + +MyBatis-Spring-Boot-Starter 将自动寻找实现了 `ConfigurationCustomizer` 接口的组件,调用自定义 MyBatis 配置的方法。( 1.2.1 及以上的版本可用) + +例如: + +```java +@Configuration +public class MyBatisConfig { + @Bean + ConfigurationCustomizer mybatisConfigurationCustomizer() { + return new ConfigurationCustomizer() { + @Override + public void customize(Configuration configuration) { + // customize ... + } + }; + } +} +``` + +## 使用 SqlSessionFactoryBeanCustomizer + +MyBatis-Spring-Boot-Starter 提供了使用 Java Config 来自定义自动配置生成的 `SqlSessionFactoryBean` 。 + +MyBatis-Spring-Boot-Starter 将自动寻找实现了 `SqlSessionFactoryBeanCustomizer` 接口的组件,调用自定义 `SqlSessionFactoryBean` 的方法。( 2.2.2 及以上的版本可用) + +For example: + +```java +@Configuration +public class MyBatisConfig { + @Bean + SqlSessionFactoryBeanCustomizer sqlSessionFactoryBeanCustomizer() { + return new SqlSessionFactoryBeanCustomizer() { + @Override + public void customize(SqlSessionFactoryBean factoryBean) { + // customize ... + } + }; + } +} +``` + +## 使用 SpringBootVFS + +MyBatis-Spring-Boot-Starter 提供了 `SpringBootVFS` 作为 `VFS` 的实现类。 + `VFS` 用于从应用或应用服务器中寻找类 (例如: 类型别名的目标类,类型处理器类) 。 +如果你使用可执行的 jar 文件来运行 Spring boot 应用,你需要使用 `SpringBootVFS` 。 +由于拥有自动配置的特性,MyBatis-Spring-Boot-Starter 会自动启用它。 +但在你手动配置(MyBatis-Spring-Boot-Starter)的时候 (例如: 当你使用多个 `DataSource` 的时候)。 + +在手动配置(MyBatis-Spring-Boot-Starter)的时候,这样使用 `SpringBootVFS` : + +```java +@Configuration +public class MyBatisConfig { + @Bean + public SqlSessionFactory masterSqlSessionFactory() throws Exception { + SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + factoryBean.setDataSource(masterDataSource()); + factoryBean.setVfs(SpringBootVFS.class); // Sets the SpringBootVFS class into SqlSessionFactoryBean + // ... + return factoryBean.getObject(); + } +} +``` + +## 探测 MyBatis 组件 + +The MyBatis-Spring-Boot-Starter 将检测实现以下由 MyBatis 提供的接口的组件。 + +* [`Interceptor`](http://www.mybatis.org/mybatis-3/zh_CN/configuration.html#plugins) (拦截器) +* [`TypeHandler`](http://www.mybatis.org/mybatis-3/zh_CN/configuration.html#typeHandlers) (类型处理器) +* [`LanguageDriver`](http://www.mybatis.org/mybatis-3/zh_CN/dynamic-sql.html#Pluggable_Scripting_Languages_For_Dynamic_SQL) (插入脚本语言)(需要 mybatis-spring 2.0.2 以上配合使用) +* [`DatabaseIdProvider`](http://www.mybatis.org/mybatis-3/zh_CN/configuration.html#databaseIdProvider) + +```java +@Configuration +public class MyBatisConfig { + @Bean + MyInterceptor myInterceptor() { + return MyInterceptor(); + } + @Bean + MyTypeHandler myTypeHandler() { + return MyTypeHandler(); + } + @Bean + MyLanguageDriver myLanguageDriver() { + return MyLanguageDriver(); + } + @Bean + VendorDatabaseIdProvider databaseIdProvider() { + VendorDatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider(); + Properties properties = new Properties(); + properties.put("SQL Server", "sqlserver"); + properties.put("DB2", "db2"); + properties.put("H2", "h2"); + databaseIdProvider.setProperties(properties); + return databaseIdProvider; + } +} +``` + +注意: 如果只有一个 `LangaugeDriver` ,它将自动地将其作为默认的脚本语言。 + +如果你想自定义 `LangaugeDriver` 的配置,请注册用户定义的组件。 + +### ThymeleafLanguageDriver + +```java +@Configuration +public class MyBatisConfig { + @Bean + ThymeleafLanguageDriverConfig thymeleafLanguageDriverConfig() { + return ThymeleafLanguageDriverConfig.newInstance(c -> { + // ... 自定义代码 + }); + } +} +``` + +### FreeMarkerLanguageDriverConfig + +```java +@Configuration +public class MyBatisConfig { + @Bean + FreeMarkerLanguageDriverConfig freeMarkerLanguageDriverConfig() { + return FreeMarkerLanguageDriverConfig.newInstance(c -> { + // ... 自定义代码 + }); + } +} +``` + +### VelocityLanguageDriver + +```java +@Configuration +public class MyBatisConfig { + @Bean + VelocityLanguageDriverConfig velocityLanguageDriverConfig() { + return VelocityLanguageDriverConfig.newInstance(c -> { + // ... customization code + }); + } +} +``` + +### 可以运行的样例 + +项目(为每个分类)提供了至少两个样例,可以为你所用。 + +| 分类 | 样例 | 描述 | +|:-------------- |:----------------------------------------------------------------------------------------------------------------------------------- |:--------------------------------------------------------------------- | +| 核心组件 | [样例1](https://github.com/mybatis/spring-boot-starter/tree/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation) | 展示了最简单的场景,只有一个 mapper 和一个注入 mapper 的组件。这就是我们在“快速入门”部分看到的例子。 | +| | [样例2](https://github.com/mybatis/spring-boot-starter/tree/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml) | 展示了如何在 XML 文件中使用一个带有语句的 Mapper,并且也有使用 `SqlSessionTemplate` 的 DAO 的示例。 | +| LanguageDriver | [样例3](https://github.com/mybatis/spring-boot-starter/tree/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf) | 展示了如何在 mybatis-thymeleaf 的帮助下,使用 Thymeleaf。 | +| | [样例4](https://github.com/mybatis/spring-boot-starter/tree/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker) | 展示了如何在 mybatis-freemarker 的帮助下,使用 Freemarker。 | +| | [样例5](https://github.com/mybatis/spring-boot-starter/tree/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity) | 展示了如何在 mybatis-velocity 的帮助下,使用 Velocity。 | +| JVM 语言 | [样例6](https://github.com/mybatis/spring-boot-starter/tree/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin) | 展示了如何和 kotlin 一同使用。 | +| | [样例7](https://github.com/mybatis/spring-boot-starter/tree/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy) | 展示了如何和 groovy 一同使用。 | +| Web | [样例8](https://github.com/mybatis/spring-boot-starter/tree/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web) | 展示了如何在 web 环境中使用。 | +| | [样例9](https://github.com/mybatis/spring-boot-starter/tree/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war) | 展示了如何在 web 环境中使用并且让 war 文件部署在应用程序服务器上。 | diff --git a/mybatis-spring-boot-autoconfigure/src/test/java/com/example/mapper/DateTimeMapper.java b/mybatis-spring-boot-autoconfigure/src/test/java/com/example/mapper/DateTimeMapper.java index 2de96fc4..3fbd3a5d 100644 --- a/mybatis-spring-boot-autoconfigure/src/test/java/com/example/mapper/DateTimeMapper.java +++ b/mybatis-spring-boot-autoconfigure/src/test/java/com/example/mapper/DateTimeMapper.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/AdditionalConfigurationMetadataTest.java b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/AdditionalConfigurationMetadataTest.java index 212fb237..a60f5531 100644 --- a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/AdditionalConfigurationMetadataTest.java +++ b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/AdditionalConfigurationMetadataTest.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -32,6 +32,7 @@ * Tests for definition of additional-spring-configuration-metadata.json. * * @author Kazuki Shimizu + * * @since 1.3.1 */ class AdditionalConfigurationMetadataTest { @@ -45,47 +46,27 @@ void testProperties() throws IOException { List> properties = documentContext.read("$.properties"); - assertAll(() -> assertThat(properties.size()).isEqualTo(6), () -> { - // assert for mybatis.configuration.default-scripting-language - Map element = properties.get(0); - assertThat(element.get("sourceType")).isEqualTo("org.apache.ibatis.session.Configuration"); - assertThat(element.get("defaultValue")).isEqualTo("org.apache.ibatis.scripting.xmltags.XMLLanguageDriver"); - assertThat(element.get("name")).isEqualTo("mybatis.configuration.default-scripting-language"); - assertThat(element.get("type")) - .isEqualTo("java.lang.Class"); - @SuppressWarnings("unchecked") - Map deprecation = (Map) element.get("deprecation"); - assertThat(deprecation.get("reason")).isEqualTo( - "Because when this configuration property is used, there is case that custom language driver cannot be registered correctly."); - assertThat(deprecation.get("replacement")).isEqualTo("mybatis.default-scripting-language-driver"); - }, () -> { - // assert for mybatis.configuration.default-enum-type-handler - Map element = properties.get(1); - assertThat(element.get("sourceType")).isEqualTo("org.apache.ibatis.session.Configuration"); - assertThat(element.get("defaultValue")).isEqualTo("org.apache.ibatis.type.EnumTypeHandler"); - assertThat(element.get("name")).isEqualTo("mybatis.configuration.default-enum-type-handler"); - assertThat(element.get("type")).isEqualTo("java.lang.Class"); - }, () -> { + assertAll(() -> assertThat(properties.size()).isEqualTo(4), () -> { // assert for mybatis.lazy-initialization - Map element = properties.get(2); + Map element = properties.get(0); assertThat(element.get("defaultValue")).isEqualTo(false); assertThat(element.get("name")).isEqualTo("mybatis.lazy-initialization"); assertThat(element.get("type")).isEqualTo("java.lang.Boolean"); }, () -> { // assert for mybatis.mapper-default-scope - Map element = properties.get(3); + Map element = properties.get(1); assertThat(element.get("defaultValue")).isEqualTo(""); assertThat(element.get("name")).isEqualTo("mybatis.mapper-default-scope"); assertThat(element.get("type")).isEqualTo("java.lang.String"); }, () -> { // assert for mybatis.inject-sql-session-on-mapper-scan - Map element = properties.get(4); + Map element = properties.get(2); assertThat(element.get("defaultValue")).isEqualTo(true); assertThat(element.get("name")).isEqualTo("mybatis.inject-sql-session-on-mapper-scan"); assertThat(element.get("type")).isEqualTo("java.lang.Boolean"); }, () -> { // assert for mybatis.scripting-language-driver.velocity.userdirective - Map element = properties.get(5); + Map element = properties.get(3); assertThat(element.get("name")).isEqualTo("mybatis.scripting-language-driver.velocity.userdirective"); @SuppressWarnings("unchecked") Map deprecation = (Map) element.get("deprecation"); diff --git a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/MybatisAutoConfigurationTest.java b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/MybatisAutoConfigurationTest.java index f12e835b..77a8e413 100644 --- a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/MybatisAutoConfigurationTest.java +++ b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/MybatisAutoConfigurationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2022 the original author or authors. + * Copyright 2015-2024 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -16,7 +16,6 @@ package org.mybatis.spring.boot.autoconfigure; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; import com.example.mapper.DateTimeMapper; @@ -50,8 +49,7 @@ import org.apache.ibatis.type.BaseTypeHandler; import org.apache.ibatis.type.JdbcType; import org.apache.ibatis.type.TypeHandlerRegistry; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; +import org.flywaydb.core.Flyway; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.mybatis.scripting.freemarker.FreeMarkerLanguageDriver; @@ -70,23 +68,28 @@ import org.springframework.aop.scope.ScopedProxyFactoryBean; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanCreationException; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.PropertiesFactoryBean; import org.springframework.beans.factory.config.RuntimeBeanReference; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; +import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration; +import org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer; import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; -import org.springframework.boot.test.util.TestPropertyValues; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.context.support.SimpleThreadScope; +import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; +import liquibase.integration.spring.SpringLiquibase; + /** * Tests for {@link MybatisAutoConfiguration} * @@ -96,726 +99,777 @@ */ class MybatisAutoConfigurationTest { - private AnnotationConfigApplicationContext context; - - @BeforeEach - void init() { - this.context = new AnnotationConfigApplicationContext(); - } - - @AfterEach - void closeContext() { - if (this.context != null) { - this.context.close(); - } - } + private ApplicationContextRunner contextRunner = new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(MybatisAutoConfiguration.class)); @Test void testNoDataSource() { - this.context.register(MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).isEmpty(); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).isEmpty(); - assertThat(this.context.getBeanNamesForType(MybatisProperties.class)).isEmpty(); + this.contextRunner.withUserConfiguration(PropertyPlaceholderAutoConfiguration.class).run(context -> { + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).isEmpty(); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).isEmpty(); + assertThat(context.getBeanNamesForType(MybatisProperties.class)).isEmpty(); + }); } @Test void testMultipleDataSource() { - this.context.register(MultipleDataSourceConfiguration.class, MybatisAutoConfiguration.class, - PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).isEmpty(); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).isEmpty(); - assertThat(this.context.getBeanNamesForType(MybatisProperties.class)).isEmpty(); + this.contextRunner + .withUserConfiguration(MultipleDataSourceConfiguration.class, PropertyPlaceholderAutoConfiguration.class) + .run(context -> { + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).isEmpty(); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).isEmpty(); + assertThat(context.getBeanNamesForType(MybatisProperties.class)).isEmpty(); + }); } @Test void testSingleCandidateDataSource() { - this.context.register(SingleCandidateDataSourceConfiguration.class, MybatisAutoConfiguration.class, - PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(MybatisProperties.class)).hasSize(1); + this.contextRunner + .withUserConfiguration(SingleCandidateDataSourceConfiguration.class, PropertyPlaceholderAutoConfiguration.class) + .run(context -> { + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBeanNamesForType(MybatisProperties.class)).hasSize(1); + }); } @Test void testDefaultConfiguration() { - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisScanMapperConfiguration.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - SqlSessionFactory sqlSessionFactory = this.context.getBean(SqlSessionFactory.class); - assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(DateTimeMapper.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()).isFalse(); - Map languageDriverBeans = this.context.getBeansOfType(LanguageDriver.class); - assertThat(languageDriverBeans).hasSize(3).containsKeys("freeMarkerLanguageDriver", "velocityLanguageDriver", - "thymeleafLanguageDriver"); - assertThat(languageDriverBeans.get("freeMarkerLanguageDriver")).isInstanceOf(FreeMarkerLanguageDriver.class); - assertThat(languageDriverBeans.get("velocityLanguageDriver")).isInstanceOf(VelocityLanguageDriver.class); - assertThat(languageDriverBeans.get("thymeleafLanguageDriver")).isInstanceOf(ThymeleafLanguageDriver.class); - LanguageDriverRegistry languageDriverRegistry = sqlSessionFactory.getConfiguration().getLanguageRegistry(); - assertThat(languageDriverRegistry.getDefaultDriverClass()).isEqualTo(XMLLanguageDriver.class); - assertThat(languageDriverRegistry.getDefaultDriver()).isInstanceOf(XMLLanguageDriver.class); - assertThat(languageDriverRegistry.getDriver(XMLLanguageDriver.class)).isNotNull(); - assertThat(languageDriverRegistry.getDriver(RawLanguageDriver.class)).isNotNull(); - assertThat(languageDriverRegistry.getDriver(FreeMarkerLanguageDriver.class)).isNotNull(); - assertThat(languageDriverRegistry.getDriver(VelocityLanguageDriver.class)).isNotNull(); - assertThat(languageDriverRegistry.getDriver(ThymeleafLanguageDriver.class)).isNotNull(); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisLanguageDriverAutoConfiguration.class, + MybatisScanMapperConfiguration.class, PropertyPlaceholderAutoConfiguration.class) + .run(context -> { + SqlSessionFactory sqlSessionFactory = context.getBean(SqlSessionFactory.class); + assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBeanNamesForType(DateTimeMapper.class)).hasSize(1); + assertThat(context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()) + .isFalse(); + Map languageDriverBeans = context.getBeansOfType(LanguageDriver.class); + assertThat(languageDriverBeans).hasSize(3).containsKeys("freeMarkerLanguageDriver", "velocityLanguageDriver", + "thymeleafLanguageDriver"); + assertThat(languageDriverBeans.get("freeMarkerLanguageDriver")).isInstanceOf(FreeMarkerLanguageDriver.class); + assertThat(languageDriverBeans.get("velocityLanguageDriver")).isInstanceOf(VelocityLanguageDriver.class); + assertThat(languageDriverBeans.get("thymeleafLanguageDriver")).isInstanceOf(ThymeleafLanguageDriver.class); + LanguageDriverRegistry languageDriverRegistry = sqlSessionFactory.getConfiguration().getLanguageRegistry(); + assertThat(languageDriverRegistry.getDefaultDriverClass()).isEqualTo(XMLLanguageDriver.class); + assertThat(languageDriverRegistry.getDefaultDriver()).isInstanceOf(XMLLanguageDriver.class); + assertThat(languageDriverRegistry.getDriver(XMLLanguageDriver.class)).isNotNull(); + assertThat(languageDriverRegistry.getDriver(RawLanguageDriver.class)).isNotNull(); + assertThat(languageDriverRegistry.getDriver(FreeMarkerLanguageDriver.class)).isNotNull(); + assertThat(languageDriverRegistry.getDriver(VelocityLanguageDriver.class)).isNotNull(); + assertThat(languageDriverRegistry.getDriver(ThymeleafLanguageDriver.class)).isNotNull(); + }); } @Test void testScanWithLazy() { - TestPropertyValues.of("mybatis.lazy-initialization:true").applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisScanMapperConfiguration.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - SqlSessionFactory sqlSessionFactory = this.context.getBean(SqlSessionFactory.class); - assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(0); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(DateTimeMapper.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()).isFalse(); - this.context.getBean(DateTimeMapper.class); - assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisScanMapperConfiguration.class, + PropertyPlaceholderAutoConfiguration.class) + .withPropertyValues("mybatis.lazy-initialization:true").run(context -> { + SqlSessionFactory sqlSessionFactory = context.getBean(SqlSessionFactory.class); + assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(0); + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBeanNamesForType(DateTimeMapper.class)).hasSize(1); + assertThat(context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()) + .isFalse(); + context.getBean(DateTimeMapper.class); + assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); + }); } @Test void testAutoScanWithDefault() { - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - SqlSessionFactory sqlSessionFactory = this.context.getBean(SqlSessionFactory.class); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(CityMapper.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()).isFalse(); - this.context.getBean(CityMapper.class); - assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); - assertThat(((RuntimeBeanReference) this.context.getBeanDefinition("cityMapper").getPropertyValues() - .getPropertyValue("sqlSessionTemplate").getValue()).getBeanName()).isEqualTo("sqlSessionTemplate"); - assertThat( - this.context.getBeanDefinition(this.context.getBeanNamesForType(MapperScannerConfigurer.class)[0]).getRole()) - .isEqualTo(BeanDefinition.ROLE_INFRASTRUCTURE); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, + PropertyPlaceholderAutoConfiguration.class, CityMapperRepositoryConfiguration.class) + .run(context -> { + SqlSessionFactory sqlSessionFactory = context.getBean(SqlSessionFactory.class); + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBeanNamesForType(CityMapper.class)).hasSize(1); + assertThat(context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()) + .isFalse(); + context.getBean(CityMapper.class); + assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); + assertThat(((RuntimeBeanReference) context.getBeanFactory().getBeanDefinition("cityMapper") + .getPropertyValues().getPropertyValue("sqlSessionTemplate").getValue()).getBeanName()) + .isEqualTo("sqlSessionTemplate"); + assertThat(context.getBeanFactory() + .getBeanDefinition(context.getBeanNamesForType(MapperScannerConfigurer.class)[0]).getRole()) + .isEqualTo(BeanDefinition.ROLE_INFRASTRUCTURE); + }); } @Test void testAutoScanWithInjectSqlSessionOnMapperScanIsFalse() { - TestPropertyValues.of("mybatis.inject-sql-session-on-mapper-scan:false").applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - SqlSessionFactory sqlSessionFactory = this.context.getBean(SqlSessionFactory.class); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(CityMapper.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()).isFalse(); - this.context.getBean(CityMapper.class); - assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); - assertThat(this.context.getBeanDefinition("cityMapper").getPropertyValues().getPropertyValue("sqlSessionTemplate")) - .isNull(); - assertThat(this.context.getBeanDefinition("cityMapper").getPropertyValues().getPropertyValue("sqlSessionFactory")) - .isNull(); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, + PropertyPlaceholderAutoConfiguration.class, CityMapperRepositoryConfiguration.class) + .withPropertyValues("mybatis.inject-sql-session-on-mapper-scan:false").run(context -> { + SqlSessionFactory sqlSessionFactory = context.getBean(SqlSessionFactory.class); + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBeanNamesForType(CityMapper.class)).hasSize(1); + assertThat(context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()) + .isFalse(); + context.getBean(CityMapper.class); + assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); + assertThat(context.getBeanFactory().getBeanDefinition("cityMapper").getPropertyValues() + .getPropertyValue("sqlSessionTemplate")).isNull(); + assertThat(context.getBeanFactory().getBeanDefinition("cityMapper").getPropertyValues() + .getPropertyValue("sqlSessionFactory")).isNull(); + }); } @Test void testAutoScanWithLazy() { - TestPropertyValues.of("mybatis.lazy-initialization:true").applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - SqlSessionFactory sqlSessionFactory = this.context.getBean(SqlSessionFactory.class); - assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(0); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(CityMapper.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()).isFalse(); - this.context.getBean(CityMapper.class); - assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, + PropertyPlaceholderAutoConfiguration.class, CityMapperRepositoryConfiguration.class) + .withPropertyValues("mybatis.lazy-initialization:true").run(context -> { + SqlSessionFactory sqlSessionFactory = context.getBean(SqlSessionFactory.class); + assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(0); + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBeanNamesForType(CityMapper.class)).hasSize(1); + assertThat(context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()) + .isFalse(); + context.getBean(CityMapper.class); + assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); + }); } @Test void testAutoScanWithDefaultScope() { - TestPropertyValues.of("mybatis.mapper-default-scope:thread").applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - { - this.context.getBean(CityMapper.class); - BeanDefinition bd = this.context.getBeanDefinition("cityMapper"); - assertThat(bd.getBeanClassName()).isEqualTo(ScopedProxyFactoryBean.class.getName()); - BeanDefinition spbd = this.context.getBeanDefinition("scopedTarget.cityMapper"); - assertThat(spbd.getBeanClassName()).isEqualTo(MapperFactoryBean.class.getName()); - assertThat(spbd.getScope()).isEqualTo("thread"); - } + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, + PropertyPlaceholderAutoConfiguration.class, CityMapperRepositoryConfiguration.class) + .withPropertyValues("mybatis.mapper-default-scope:thread").run(context -> { + context.getBean(CityMapper.class); + BeanDefinition bd = context.getBeanFactory().getBeanDefinition("cityMapper"); + assertThat(bd.getBeanClassName()).isEqualTo(ScopedProxyFactoryBean.class.getName()); + BeanDefinition spbd = context.getBeanFactory().getBeanDefinition("scopedTarget.cityMapper"); + assertThat(spbd.getBeanClassName()).isEqualTo(MapperFactoryBean.class.getName()); + assertThat(spbd.getScope()).isEqualTo("thread"); + }); } @Test void testAutoScanWithoutDefaultScope() { - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - { - this.context.getBean(CityMapper.class); - BeanDefinition df = this.context.getBeanDefinition("cityMapper"); - assertThat(df.getBeanClassName()).isEqualTo(MapperFactoryBean.class.getName()); - assertThat(df.getScope()).isEqualTo("singleton"); - } + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, + PropertyPlaceholderAutoConfiguration.class, CityMapperRepositoryConfiguration.class) + .run(context -> { + context.getBean(CityMapper.class); + BeanDefinition df = context.getBeanFactory().getBeanDefinition("cityMapper"); + assertThat(df.getBeanClassName()).isEqualTo(MapperFactoryBean.class.getName()); + assertThat(df.getScope()).isEqualTo("singleton"); + }); } @Test void testWithConfigLocation() { - TestPropertyValues.of("mybatis.config-location:mybatis-config.xml").applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class, - MybatisMapperConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(CityMapperImpl.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.BATCH); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()).isTrue(); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisMapperConfiguration.class, + PropertyPlaceholderAutoConfiguration.class) + .withPropertyValues("mybatis.config-location:mybatis-config.xml").run(context -> { + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(CityMapperImpl.class)).hasSize(1); + assertThat(context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.BATCH); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()).isTrue(); + }); } @Test void testWithCheckConfigLocationFileExists() { - TestPropertyValues.of("mybatis.config-location:mybatis-config.xml", "mybatis.check-config-location=true") - .applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class) + .withPropertyValues("mybatis.config-location:mybatis-config.xml", "mybatis.check-config-location=true") + .run(context -> assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1)); } @Test void testWithCheckConfigLocationFileNotSpecify() { - TestPropertyValues.of("mybatis.check-config-location=true").applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.check-config-location=true") + .run(context -> assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1)); } @Test void testWithCheckConfigLocationFileDoesNotExists() { - - TestPropertyValues.of("mybatis.config-location:foo.xml", "mybatis.check-config-location=true") - .applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class); - - try { - this.context.refresh(); - fail("Should be occurred a BeanCreationException."); - } catch (BeanCreationException e) { - assertThat(e.getMessage()).isEqualTo( - "Error creating bean with name 'mybatisAutoConfiguration': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Cannot find config location: class path resource [foo.xml] (please add config file or check your Mybatis configuration)"); - } + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.config-location:foo.xml", "mybatis.check-config-location=true") + .run(context -> assertThat(context).getFailure().isInstanceOf(BeanCreationException.class).hasMessageContaining( + "Cannot find config location: class path resource [foo.xml] (please add config file or check your Mybatis configuration)")); } @Test void testWithTypeHandlersPackage() { - TestPropertyValues.of("mybatis.type-handlers-package:org.mybatis.spring.boot.autoconfigure.handler") - .applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class, - PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - - TypeHandlerRegistry typeHandlerRegistry = this.context.getBean(SqlSessionFactory.class).getConfiguration() - .getTypeHandlerRegistry(); - assertThat(typeHandlerRegistry.hasTypeHandler(BigInteger.class)).isTrue(); - assertThat(typeHandlerRegistry.hasTypeHandler(AtomicInteger.class)).isTrue(); - assertThat(typeHandlerRegistry.hasTypeHandler(AtomicLong.class)).isTrue(); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, PropertyPlaceholderAutoConfiguration.class) + .withPropertyValues("mybatis.type-handlers-package:org.mybatis.spring.boot.autoconfigure.handler") + .run(context -> { + TypeHandlerRegistry typeHandlerRegistry = context.getBean(SqlSessionFactory.class).getConfiguration() + .getTypeHandlerRegistry(); + assertThat(typeHandlerRegistry.hasTypeHandler(BigInteger.class)).isTrue(); + assertThat(typeHandlerRegistry.hasTypeHandler(AtomicInteger.class)).isTrue(); + assertThat(typeHandlerRegistry.hasTypeHandler(AtomicLong.class)).isTrue(); + }); } @Test void testWithMapperLocation() { - TestPropertyValues - .of("mybatis.type-aliases-package:org.mybatis.spring.boot.autoconfigure.domain", + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, PropertyPlaceholderAutoConfiguration.class) + .withPropertyValues("mybatis.type-aliases-package:org.mybatis.spring.boot.autoconfigure.domain", "mybatis.mapper-locations:classpath:org/mybatis/spring/boot/autoconfigure/repository/CityMapper.xml") - .applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class, - PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().getMappedStatementNames()).hasSize(2); + .run( + context -> assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getMappedStatementNames()) + .hasSize(2)); } @Test void testWithExecutorType() { - TestPropertyValues.of("mybatis.config-location:mybatis-config.xml", "mybatis.executor-type:REUSE") - .applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class, - MybatisMapperConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.REUSE); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisMapperConfiguration.class, + PropertyPlaceholderAutoConfiguration.class) + .withPropertyValues("mybatis.config-location:mybatis-config.xml", "mybatis.executor-type:REUSE") + .run(context -> assertThat(context.getBean(SqlSessionTemplate.class).getExecutorType()) + .isEqualTo(ExecutorType.REUSE)); } @Test void testDefaultBootConfiguration() { - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - SqlSessionFactory sqlSessionFactory = this.context.getBean(SqlSessionFactory.class); - assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(CityMapper.class)).hasSize(1); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, + PropertyPlaceholderAutoConfiguration.class, CityMapperRepositoryConfiguration.class) + .run(context -> { + SqlSessionFactory sqlSessionFactory = context.getBean(SqlSessionFactory.class); + assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBeanNamesForType(CityMapper.class)).hasSize(1); + }); } @Test void testWithInterceptorsOrder1() { - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisInterceptorConfiguration.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().getInterceptors()).hasSize(2); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().getInterceptors().get(0)) - .isInstanceOf(MyInterceptor2.class); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().getInterceptors().get(1)) - .isInstanceOf(MyInterceptor.class); - - this.context.close(); + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, + MybatisInterceptorConfiguration.class, PropertyPlaceholderAutoConfiguration.class).run(context -> { + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getInterceptors()).hasSize(2); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getInterceptors().get(0)) + .isInstanceOf(MyInterceptor2.class); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getInterceptors().get(1)) + .isInstanceOf(MyInterceptor.class); + }); } @Test void testWithInterceptorsOrder2() { - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisInterceptorConfiguration2.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().getInterceptors()).hasSize(2); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().getInterceptors().get(0)) - .isInstanceOf(MyInterceptor.class); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().getInterceptors().get(1)) - .isInstanceOf(MyInterceptor2.class); - - this.context.close(); + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, + MybatisInterceptorConfiguration2.class, PropertyPlaceholderAutoConfiguration.class).run(context -> { + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getInterceptors()).hasSize(2); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getInterceptors().get(0)) + .isInstanceOf(MyInterceptor.class); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getInterceptors().get(1)) + .isInstanceOf(MyInterceptor2.class); + }); } @Test void testWithTypeHandlers() { - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisTypeHandlerConfiguration.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().getTypeHandlerRegistry() - .getTypeHandler(UUID.class)).isInstanceOf(MyTypeHandler.class); - this.context.close(); + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, + MybatisTypeHandlerConfiguration.class, PropertyPlaceholderAutoConfiguration.class).run(context -> { + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getTypeHandlerRegistry() + .getTypeHandler(UUID.class)).isInstanceOf(MyTypeHandler.class); + }); } @Test void testWithDatabaseIdProvider() { - this.context.register(EmbeddedDataSourceConfiguration.class, DatabaseProvidersConfiguration.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().getDatabaseId()).isEqualTo("h2"); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, DatabaseProvidersConfiguration.class, + PropertyPlaceholderAutoConfiguration.class) + .run(context -> assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getDatabaseId()) + .isEqualTo("h2")); } @Test void testMixedWithConfigurationFileAndInterceptor() { - TestPropertyValues.of("mybatis.config-location:mybatis-config-settings-only.xml").applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisInterceptorConfiguration.class); - this.context.refresh(); - - org.apache.ibatis.session.Configuration configuration = this.context.getBean(SqlSessionFactory.class) - .getConfiguration(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(CityMapper.class)).hasSize(1); - assertThat(configuration.getDefaultFetchSize()).isEqualTo(1000); - assertThat(configuration.getInterceptors()).hasSize(2); - assertThat(configuration.getInterceptors().get(0)).isInstanceOf(MyInterceptor2.class); - assertThat(configuration.getInterceptors().get(1)).isInstanceOf(MyInterceptor.class); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisInterceptorConfiguration.class, + CityMapperRepositoryConfiguration.class) + .withPropertyValues("mybatis.config-location:mybatis-config-settings-only.xml").run(context -> { + org.apache.ibatis.session.Configuration configuration = context.getBean(SqlSessionFactory.class) + .getConfiguration(); + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBeanNamesForType(CityMapper.class)).hasSize(1); + assertThat(configuration.getDefaultFetchSize()).isEqualTo(1000); + assertThat(configuration.getInterceptors()).hasSize(2); + assertThat(configuration.getInterceptors().get(0)).isInstanceOf(MyInterceptor2.class); + assertThat(configuration.getInterceptors().get(1)).isInstanceOf(MyInterceptor.class); + }); } @Test void testMixedWithConfigurationFileAndDatabaseIdProvider() { - TestPropertyValues.of("mybatis.config-location:mybatis-config-settings-only.xml").applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, - DatabaseProvidersConfiguration.class); - this.context.refresh(); - - org.apache.ibatis.session.Configuration configuration = this.context.getBean(SqlSessionFactory.class) - .getConfiguration(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(CityMapper.class)).hasSize(1); - assertThat(configuration.getDefaultFetchSize()).isEqualTo(1000); - assertThat(configuration.getDatabaseId()).isEqualTo("h2"); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, + DatabaseProvidersConfiguration.class, CityMapperRepositoryConfiguration.class) + .withPropertyValues("mybatis.config-location:mybatis-config-settings-only.xml").run(context -> { + org.apache.ibatis.session.Configuration configuration = context.getBean(SqlSessionFactory.class) + .getConfiguration(); + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBeanNamesForType(CityMapper.class)).hasSize(1); + assertThat(configuration.getDefaultFetchSize()).isEqualTo(1000); + assertThat(configuration.getDatabaseId()).isEqualTo("h2"); + }); } @Test void testMixedWithConfigurationFileAndTypeHandlersPackage() { - TestPropertyValues.of("mybatis.config-location:mybatis-config-settings-only.xml", - "mybatis.type-handlers-package:org.mybatis.spring.boot.autoconfigure.handler.").applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class); - this.context.refresh(); - - org.apache.ibatis.session.Configuration configuration = this.context.getBean(SqlSessionFactory.class) - .getConfiguration(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(CityMapper.class)).hasSize(1); - assertThat(configuration.getDefaultFetchSize()).isEqualTo(1000); - assertThat(configuration.getTypeHandlerRegistry().getTypeHandler(BigInteger.class)) - .isInstanceOf(DummyTypeHandler.class); - assertThat(configuration.getTypeHandlerRegistry().getTypeHandler(AtomicInteger.class)) - .isInstanceOf(AtomicNumberTypeHandler.class); - assertThat(configuration.getTypeHandlerRegistry().getTypeHandler(AtomicLong.class)) - .isInstanceOf(AtomicNumberTypeHandler.class); - assertThat(configuration.getTypeHandlerRegistry().getTypeHandler(AtomicInteger.class).toString()) - .isEqualTo("type=" + AtomicInteger.class); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, + CityMapperRepositoryConfiguration.class) + .withPropertyValues("mybatis.config-location:mybatis-config-settings-only.xml", + "mybatis.type-handlers-package:org.mybatis.spring.boot.autoconfigure.handler.") + .run(context -> { + org.apache.ibatis.session.Configuration configuration = context.getBean(SqlSessionFactory.class) + .getConfiguration(); + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBeanNamesForType(CityMapper.class)).hasSize(1); + assertThat(configuration.getDefaultFetchSize()).isEqualTo(1000); + assertThat(configuration.getTypeHandlerRegistry().getTypeHandler(BigInteger.class)) + .isInstanceOf(DummyTypeHandler.class); + assertThat(configuration.getTypeHandlerRegistry().getTypeHandler(AtomicInteger.class)) + .isInstanceOf(AtomicNumberTypeHandler.class); + assertThat(configuration.getTypeHandlerRegistry().getTypeHandler(AtomicLong.class)) + .isInstanceOf(AtomicNumberTypeHandler.class); + assertThat(configuration.getTypeHandlerRegistry().getTypeHandler(AtomicInteger.class)) + .hasToString("type=" + AtomicInteger.class); + }); } @Test void testMixedWithConfigurationFileAndTypeAliasesPackageAndMapperLocations() { - TestPropertyValues - .of("mybatis.config-location:mybatis-config-settings-only.xml", + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, + CityMapperRepositoryConfiguration.class) + .withPropertyValues("mybatis.config-location:mybatis-config-settings-only.xml", "mybatis.type-aliases-package:org.mybatis.spring.boot.autoconfigure.domain", "mybatis.mapper-locations:classpath:org/mybatis/spring/boot/autoconfigure/repository/CityMapper.xml") - .applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class); - this.context.refresh(); - - org.apache.ibatis.session.Configuration configuration = this.context.getBean(SqlSessionFactory.class) - .getConfiguration(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(CityMapper.class)).hasSize(1); - assertThat(configuration.getDefaultFetchSize()).isEqualTo(1000); - assertThat(configuration.getMappedStatementNames()).contains("selectCityById"); - assertThat(configuration.getMappedStatementNames()) - .contains("org.mybatis.spring.boot.autoconfigure.repository.CityMapperImpl.selectCityById"); - assertThat(configuration.getTypeAliasRegistry().getTypeAliases()).containsKey("city"); - assertThat(configuration.getTypeAliasRegistry().getTypeAliases()).containsKey("name"); + .run(context -> { + org.apache.ibatis.session.Configuration configuration = context.getBean(SqlSessionFactory.class) + .getConfiguration(); + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBeanNamesForType(CityMapper.class)).hasSize(1); + assertThat(configuration.getDefaultFetchSize()).isEqualTo(1000); + assertThat(configuration.getMappedStatementNames()).contains("selectCityById"); + assertThat(configuration.getMappedStatementNames()) + .contains("org.mybatis.spring.boot.autoconfigure.repository.CityMapperImpl.selectCityById"); + assertThat(configuration.getTypeAliasRegistry().getTypeAliases()).containsKey("city"); + assertThat(configuration.getTypeAliasRegistry().getTypeAliases()).containsKey("name"); + }); } @Test void testMixedWithFullConfigurations() { - TestPropertyValues.of("mybatis.config-location:mybatis-config-settings-only.xml", - "mybatis.type-handlers-package:org.mybatis.spring.**.handler", - "mybatis.type-aliases-package:org.mybatis.spring.boot.autoconfigure.domain", - "mybatis.mapper-locations:classpath:org/mybatis/spring/boot/autoconfigure/repository/CityMapper.xml", - "mybatis.executor-type=REUSE").applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, - MybatisInterceptorConfiguration.class, DatabaseProvidersConfiguration.class); - this.context.refresh(); - - org.apache.ibatis.session.Configuration configuration = this.context.getBean(SqlSessionFactory.class) - .getConfiguration(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(CityMapper.class)).hasSize(1); - assertThat(configuration.getDefaultFetchSize()).isEqualTo(1000); - assertThat(configuration.getTypeHandlerRegistry().getTypeHandler(BigInteger.class)) - .isInstanceOf(DummyTypeHandler.class); - assertThat(configuration.getTypeHandlerRegistry().getTypeHandler(AtomicInteger.class)) - .isInstanceOf(AtomicNumberTypeHandler.class); - assertThat(configuration.getTypeHandlerRegistry().getTypeHandler(AtomicLong.class)) - .isInstanceOf(AtomicNumberTypeHandler.class); - assertThat(configuration.getMappedStatementNames()).hasSize(4); - assertThat(configuration.getMappedStatementNames()).contains("selectCityById"); - assertThat(configuration.getMappedStatementNames()) - .contains("org.mybatis.spring.boot.autoconfigure.repository.CityMapperImpl.selectCityById"); - assertThat(configuration.getMappedStatementNames()).contains("findById"); - assertThat(configuration.getMappedStatementNames()) - .contains("org.mybatis.spring.boot.autoconfigure.mapper.CityMapper.findById"); - assertThat(this.context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.REUSE); - assertThat(configuration.getInterceptors()).hasSize(2); - assertThat(configuration.getInterceptors().get(0)).isInstanceOf(MyInterceptor2.class); - assertThat(configuration.getInterceptors().get(1)).isInstanceOf(MyInterceptor.class); - assertThat(configuration.getDatabaseId()).isEqualTo("h2"); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, + MybatisInterceptorConfiguration.class, DatabaseProvidersConfiguration.class, + CityMapperRepositoryConfiguration.class) + .withPropertyValues("mybatis.config-location:mybatis-config-settings-only.xml", + "mybatis.type-handlers-package:org.mybatis.spring.**.handler", + "mybatis.type-aliases-package:org.mybatis.spring.boot.autoconfigure.domain", + "mybatis.mapper-locations:classpath:org/mybatis/spring/boot/autoconfigure/repository/CityMapper.xml", + "mybatis.executor-type=REUSE") + .run(context -> { + org.apache.ibatis.session.Configuration configuration = context.getBean(SqlSessionFactory.class) + .getConfiguration(); + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBeanNamesForType(CityMapper.class)).hasSize(1); + assertThat(configuration.getDefaultFetchSize()).isEqualTo(1000); + assertThat(configuration.getTypeHandlerRegistry().getTypeHandler(BigInteger.class)) + .isInstanceOf(DummyTypeHandler.class); + assertThat(configuration.getTypeHandlerRegistry().getTypeHandler(AtomicInteger.class)) + .isInstanceOf(AtomicNumberTypeHandler.class); + assertThat(configuration.getTypeHandlerRegistry().getTypeHandler(AtomicLong.class)) + .isInstanceOf(AtomicNumberTypeHandler.class); + assertThat(configuration.getMappedStatementNames()).hasSize(4); + assertThat(configuration.getMappedStatementNames()).contains("selectCityById"); + assertThat(configuration.getMappedStatementNames()) + .contains("org.mybatis.spring.boot.autoconfigure.repository.CityMapperImpl.selectCityById"); + assertThat(configuration.getMappedStatementNames()).contains("findById"); + assertThat(configuration.getMappedStatementNames()) + .contains("org.mybatis.spring.boot.autoconfigure.mapper.CityMapper.findById"); + assertThat(context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.REUSE); + assertThat(configuration.getInterceptors()).hasSize(2); + assertThat(configuration.getInterceptors().get(0)).isInstanceOf(MyInterceptor2.class); + assertThat(configuration.getInterceptors().get(1)).isInstanceOf(MyInterceptor.class); + assertThat(configuration.getDatabaseId()).isEqualTo("h2"); + }); } @Test void testWithMyBatisConfiguration() { - TestPropertyValues.of("mybatis.configuration.map-underscore-to-camel-case:true").applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()).isTrue(); - } - - @Test - void testWithMyBatisConfigurationCustomizeByJavaConfig() { - TestPropertyValues.of("mybatis.configuration.default-fetch-size:100").applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class, - MybatisPropertiesConfigurationCustomizer.class); - this.context.refresh(); - SqlSessionFactory sqlSessionFactory = this.context.getBean(SqlSessionFactory.class); - assertThat(sqlSessionFactory.getConfiguration().getDefaultFetchSize()).isEqualTo(100); - assertThat(sqlSessionFactory.getConfiguration().getTypeHandlerRegistry().getTypeHandler(BigInteger.class)) - .isInstanceOf(DummyTypeHandler.class); + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.map-underscore-to-camel-case:true").run(context -> assertThat( + context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()).isTrue()); } @Test void testWithMyBatisConfigurationCustomizer() { - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class, - MyBatisConfigurationCustomizerConfiguration.class); - this.context.refresh(); - SqlSessionFactory sqlSessionFactory = this.context.getBean(SqlSessionFactory.class); - assertThat(sqlSessionFactory.getConfiguration().getTypeHandlerRegistry().getTypeHandler(BigInteger.class)) - .isInstanceOf(DummyTypeHandler.class); - assertThat(sqlSessionFactory.getConfiguration().getCache("test")).isNotNull(); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MyBatisConfigurationCustomizerConfiguration.class) + .run(context -> { + SqlSessionFactory sqlSessionFactory = context.getBean(SqlSessionFactory.class); + assertThat(sqlSessionFactory.getConfiguration().getTypeHandlerRegistry().getTypeHandler(BigInteger.class)) + .isInstanceOf(DummyTypeHandler.class); + assertThat(sqlSessionFactory.getConfiguration().getCache("test")).isNotNull(); + }); } @Test void testWithSqlSessionFactoryBeanCustomizer() { - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class, - SqlSessionFactoryBeanCustomizerConfiguration.class); - this.context.refresh(); - SqlSessionFactory sqlSessionFactory = this.context.getBean(SqlSessionFactory.class); - assertThat(sqlSessionFactory.getConfiguration().getTypeHandlerRegistry().getTypeHandler(BigInteger.class)) - .isInstanceOf(DummyTypeHandler.class); - assertThat(sqlSessionFactory.getConfiguration().getCache("test")).isNotNull(); + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, + SqlSessionFactoryBeanCustomizerConfiguration.class).run(context -> { + SqlSessionFactory sqlSessionFactory = context.getBean(SqlSessionFactory.class); + assertThat(sqlSessionFactory.getConfiguration().getTypeHandlerRegistry().getTypeHandler(BigInteger.class)) + .isInstanceOf(DummyTypeHandler.class); + assertThat(sqlSessionFactory.getConfiguration().getCache("test")).isNotNull(); + }); } @Test void testConfigFileAndConfigurationWithTogether() { - TestPropertyValues - .of("mybatis.config-location:mybatis-config.xml", "mybatis.configuration.default-statement-timeout:30") - .applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class); - - try { - this.context.refresh(); - fail("Should be occurred a BeanCreationException."); - } catch (BeanCreationException e) { - assertThat(e.getMessage()) - .contains("Property 'configuration' and 'configLocation' can not specified with together"); - } + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.config-location:mybatis-config.xml", + "mybatis.configuration.default-statement-timeout:30") + .run(context -> { + assertThat(context).hasFailed(); + assertThat(context).getFailure().isInstanceOf(BeanCreationException.class) + .hasMessageContaining("Property 'configuration' and 'configLocation' can not specified with together"); + }); } @Test void testWithoutConfigurationVariablesAndProperties() { - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class, - PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - - Properties variables = this.context.getBean(SqlSessionFactory.class).getConfiguration().getVariables(); - assertThat(variables).isEmpty(); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, PropertyPlaceholderAutoConfiguration.class) + .run(context -> { + Properties variables = context.getBean(SqlSessionFactory.class).getConfiguration().getVariables(); + assertThat(variables).isEmpty(); + }); } @Test void testWithConfigurationVariablesOnly() { - TestPropertyValues.of("mybatis.configuration.variables.key1:value1").applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class, - PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - - Properties variables = this.context.getBean(SqlSessionFactory.class).getConfiguration().getVariables(); - assertThat(variables).hasSize(1); - assertThat(variables.getProperty("key1")).isEqualTo("value1"); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, PropertyPlaceholderAutoConfiguration.class) + .withPropertyValues("mybatis.configuration.variables.key1:value1").run(context -> { + Properties variables = context.getBean(SqlSessionFactory.class).getConfiguration().getVariables(); + assertThat(variables).hasSize(1); + assertThat(variables.getProperty("key1")).isEqualTo("value1"); + }); } @Test void testWithConfigurationPropertiesOnly() { - TestPropertyValues.of("mybatis.configuration-properties.key2:value2").applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class, - PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - - Properties variables = this.context.getBean(SqlSessionFactory.class).getConfiguration().getVariables(); - assertThat(variables).hasSize(1); - assertThat(variables.getProperty("key2")).isEqualTo("value2"); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, PropertyPlaceholderAutoConfiguration.class) + .withPropertyValues("mybatis.configuration-properties.key2:value2").run(context -> { + Properties variables = context.getBean(SqlSessionFactory.class).getConfiguration().getVariables(); + assertThat(variables).hasSize(1); + assertThat(variables.getProperty("key2")).isEqualTo("value2"); + }); } @Test void testWithConfigurationVariablesAndPropertiesOtherKey() { - TestPropertyValues.of("mybatis.configuration.variables.key1:value1", "mybatis.configuration-properties.key2:value2") - .applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class, - PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - - Properties variables = this.context.getBean(SqlSessionFactory.class).getConfiguration().getVariables(); - assertThat(variables).hasSize(2); - assertThat(variables.getProperty("key1")).isEqualTo("value1"); - assertThat(variables.getProperty("key2")).isEqualTo("value2"); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, PropertyPlaceholderAutoConfiguration.class) + .withPropertyValues("mybatis.configuration.variables.key1:value1", + "mybatis.configuration-properties.key2:value2") + .run(context -> { + Properties variables = context.getBean(SqlSessionFactory.class).getConfiguration().getVariables(); + assertThat(variables).hasSize(2); + assertThat(variables.getProperty("key1")).isEqualTo("value1"); + assertThat(variables.getProperty("key2")).isEqualTo("value2"); + }); } @Test void testWithConfigurationVariablesAndPropertiesSameKey() { - TestPropertyValues.of("mybatis.configuration.variables.key:value1", "mybatis.configuration-properties.key:value2") - .applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class, - PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - - Properties variables = this.context.getBean(SqlSessionFactory.class).getConfiguration().getVariables(); - assertThat(variables).hasSize(1); - assertThat(variables.getProperty("key")).isEqualTo("value2"); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, PropertyPlaceholderAutoConfiguration.class) + .withPropertyValues("mybatis.configuration.variables.key:value1", "mybatis.configuration-properties.key:value2") + .run(context -> { + Properties variables = context.getBean(SqlSessionFactory.class).getConfiguration().getVariables(); + assertThat(variables).hasSize(1); + assertThat(variables.getProperty("key")).isEqualTo("value2"); + }); } @Test void testCustomSqlSessionFactory() { - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, - CustomSqlSessionFactoryConfiguration.class, MybatisAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().getVariables().getProperty("key")) - .isEqualTo("value"); - assertThat(this.context.getBeanNamesForType(CityMapper.class)).hasSize(1); - assertThat(((RuntimeBeanReference) this.context.getBeanDefinition("cityMapper").getPropertyValues() - .getPropertyValue("sqlSessionFactory").getValue()).getBeanName()).isEqualTo("customSqlSessionFactory"); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, + CustomSqlSessionFactoryConfiguration.class, CityMapperRepositoryConfiguration.class) + .run(context -> { + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getVariables().getProperty("key")) + .isEqualTo("value"); + assertThat(context.getBeanNamesForType(CityMapper.class)).hasSize(1); + assertThat(((RuntimeBeanReference) context.getBeanFactory().getBeanDefinition("cityMapper") + .getPropertyValues().getPropertyValue("sqlSessionFactory").getValue()).getBeanName()) + .isEqualTo("customSqlSessionFactory"); + }); } @Test void testMySqlSessionFactory() { - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class, - MySqlSessionFactoryConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionFactory.class)).isInstanceOf(MySqlSessionFactory.class); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MySqlSessionFactoryConfiguration.class) + .run(context -> { + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBean(SqlSessionFactory.class)).isInstanceOf(MySqlSessionFactory.class); + }); } @Test void testCustomSqlSessionTemplate() { - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, - CustomSqlSessionTemplateConfiguration.class, MybatisAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.BATCH); - assertThat(this.context.getBeanNamesForType(CityMapper.class)).hasSize(1); - assertThat(((RuntimeBeanReference) this.context.getBeanDefinition("cityMapper").getPropertyValues() - .getPropertyValue("sqlSessionTemplate").getValue()).getBeanName()).isEqualTo("customSqlSessionTemplate"); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, + CustomSqlSessionTemplateConfiguration.class, CityMapperRepositoryConfiguration.class) + .run(context -> { + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.BATCH); + assertThat(context.getBeanNamesForType(CityMapper.class)).hasSize(1); + assertThat(((RuntimeBeanReference) context.getBeanFactory().getBeanDefinition("cityMapper") + .getPropertyValues().getPropertyValue("sqlSessionTemplate").getValue()).getBeanName()) + .isEqualTo("customSqlSessionTemplate"); + }); } @Test void testMySqlSessionTemplate() { - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisAutoConfiguration.class, - MySqlSessionTemplateConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionTemplate.class)).isInstanceOf(MySqlSessionTemplate.class); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MySqlSessionTemplateConfiguration.class) + .run(context -> { + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBean(SqlSessionTemplate.class)).isInstanceOf(MySqlSessionTemplate.class); + }); } @Test void testCustomSqlSessionTemplateAndSqlSessionFactory() { - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class, - CustomSqlSessionFactoryConfiguration.class, CustomSqlSessionTemplateConfiguration.class, - MybatisAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.BATCH); - assertThat(this.context.getBeanNamesForType(CityMapper.class)).hasSize(1); - assertThat(((RuntimeBeanReference) this.context.getBeanDefinition("cityMapper").getPropertyValues() - .getPropertyValue("sqlSessionTemplate").getValue()).getBeanName()).isEqualTo("customSqlSessionTemplate"); + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, + MybatisBootMapperScanAutoConfiguration.class, CustomSqlSessionFactoryConfiguration.class, + CustomSqlSessionTemplateConfiguration.class, CityMapperRepositoryConfiguration.class).run(context -> { + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.BATCH); + assertThat(context.getBeanNamesForType(CityMapper.class)).hasSize(1); + assertThat(((RuntimeBeanReference) context.getBeanFactory().getBeanDefinition("cityMapper") + .getPropertyValues().getPropertyValue("sqlSessionTemplate").getValue()).getBeanName()) + .isEqualTo("customSqlSessionTemplate"); + }); } @Test void testTypeAliasesSuperTypeIsSpecify() { - TestPropertyValues - .of("mybatis.type-aliases-package:org.mybatis.spring.boot.autoconfigure.domain", + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class) + .withPropertyValues("mybatis.type-aliases-package:org.mybatis.spring.boot.autoconfigure.domain", "mybatis.type-aliases-super-type:org.mybatis.spring.boot.autoconfigure.domain.Domain") - .applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class); - this.context.refresh(); - - org.apache.ibatis.session.Configuration configuration = this.context.getBean(SqlSessionFactory.class) - .getConfiguration(); - assertThat(configuration.getTypeAliasRegistry().getTypeAliases()).containsKey("city"); - assertThat(configuration.getTypeAliasRegistry().getTypeAliases()).doesNotContainKey("name"); + .run(context -> { + org.apache.ibatis.session.Configuration configuration = context.getBean(SqlSessionFactory.class) + .getConfiguration(); + assertThat(configuration.getTypeAliasRegistry().getTypeAliases()).containsKey("city"); + assertThat(configuration.getTypeAliasRegistry().getTypeAliases()).doesNotContainKey("name"); + }); } @Test void testMapperFactoryBean() { - this.context.register(EmbeddedDataSourceConfiguration.class, MapperFactoryBeanConfiguration.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - SqlSessionFactory sqlSessionFactory = this.context.getBean(SqlSessionFactory.class); - assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(DateTimeMapper.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()).isFalse(); + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, + MapperFactoryBeanConfiguration.class, PropertyPlaceholderAutoConfiguration.class).run(context -> { + SqlSessionFactory sqlSessionFactory = context.getBean(SqlSessionFactory.class); + assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBeanNamesForType(DateTimeMapper.class)).hasSize(1); + assertThat(context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()) + .isFalse(); + }); } @Test void testMapperScannerConfigurer() { - this.context.register(EmbeddedDataSourceConfiguration.class, MapperScannerConfigurerConfiguration.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - SqlSessionFactory sqlSessionFactory = this.context.getBean(SqlSessionFactory.class); - assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(DateTimeMapper.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()).isFalse(); + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, + MapperScannerConfigurerConfiguration.class, PropertyPlaceholderAutoConfiguration.class).run(context -> { + SqlSessionFactory sqlSessionFactory = context.getBean(SqlSessionFactory.class); + assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBeanNamesForType(DateTimeMapper.class)).hasSize(1); + assertThat(context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()) + .isFalse(); + }); } @Test void testDefaultScriptingLanguageIsSpecify() { - TestPropertyValues - .of("mybatis.default-scripting-language-driver:org.mybatis.scripting.thymeleaf.ThymeleafLanguageDriver") - .applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisScanMapperConfiguration.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - SqlSessionFactory sqlSessionFactory = this.context.getBean(SqlSessionFactory.class); - LanguageDriverRegistry languageDriverRegistry = sqlSessionFactory.getConfiguration().getLanguageRegistry(); - assertThat(languageDriverRegistry.getDefaultDriverClass()).isEqualTo(ThymeleafLanguageDriver.class); - assertThat(languageDriverRegistry.getDefaultDriver()).isInstanceOf(ThymeleafLanguageDriver.class); - assertThat(languageDriverRegistry.getDriver(ThymeleafLanguageDriver.class)).isNotNull(); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisScanMapperConfiguration.class, + PropertyPlaceholderAutoConfiguration.class) + .withPropertyValues( + "mybatis.default-scripting-language-driver:org.mybatis.scripting.thymeleaf.ThymeleafLanguageDriver") + .run(context -> { + SqlSessionFactory sqlSessionFactory = context.getBean(SqlSessionFactory.class); + LanguageDriverRegistry languageDriverRegistry = sqlSessionFactory.getConfiguration().getLanguageRegistry(); + assertThat(languageDriverRegistry.getDefaultDriverClass()).isEqualTo(ThymeleafLanguageDriver.class); + assertThat(languageDriverRegistry.getDefaultDriver()).isInstanceOf(ThymeleafLanguageDriver.class); + assertThat(languageDriverRegistry.getDriver(ThymeleafLanguageDriver.class)).isNotNull(); + }); } @Test void testExcludeMybatisLanguageDriverAutoConfiguration() { - TestPropertyValues - .of("spring.autoconfigure.exclude:org.mybatis.spring.boot.autoconfigure.MybatisLanguageDriverAutoConfiguration") - .applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisScanMapperConfiguration.class, - MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - SqlSessionFactory sqlSessionFactory = this.context.getBean(SqlSessionFactory.class); - assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); - assertThat(this.context.getBeanNamesForType(DateTimeMapper.class)).hasSize(1); - assertThat(this.context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); - assertThat(this.context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()).isFalse(); - assertThat(this.context.getBeanNamesForType(LanguageDriver.class)).hasSize(0); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisScanMapperConfiguration.class, + PropertyPlaceholderAutoConfiguration.class) + .withPropertyValues( + "spring.autoconfigure.exclude:org.mybatis.spring.boot.autoconfigure.MybatisLanguageDriverAutoConfiguration") + .run(context -> { + SqlSessionFactory sqlSessionFactory = context.getBean(SqlSessionFactory.class); + assertThat(sqlSessionFactory.getConfiguration().getMapperRegistry().getMappers()).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionFactory.class)).hasSize(1); + assertThat(context.getBeanNamesForType(SqlSessionTemplate.class)).hasSize(1); + assertThat(context.getBeanNamesForType(DateTimeMapper.class)).hasSize(1); + assertThat(context.getBean(SqlSessionTemplate.class).getExecutorType()).isEqualTo(ExecutorType.SIMPLE); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()) + .isFalse(); + assertThat(context.getBeanNamesForType(LanguageDriver.class)).hasSize(0); + }); } @Test void testMybatisLanguageDriverAutoConfigurationWithSingleCandidate() { - TestPropertyValues - .of("spring.autoconfigure.exclude:org.mybatis.spring.boot.autoconfigure.MybatisLanguageDriverAutoConfiguration") - .applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisScanMapperConfiguration.class, - SingleLanguageDriverConfiguration.class, MybatisAutoConfiguration.class, - PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - SqlSessionFactory sqlSessionFactory = this.context.getBean(SqlSessionFactory.class); - LanguageDriverRegistry languageDriverRegistry = sqlSessionFactory.getConfiguration().getLanguageRegistry(); - assertThat(this.context.getBeanNamesForType(LanguageDriver.class)).hasSize(1); - assertThat(languageDriverRegistry.getDefaultDriverClass()).isEqualTo(ThymeleafLanguageDriver.class); - assertThat(languageDriverRegistry.getDefaultDriver()).isInstanceOf(ThymeleafLanguageDriver.class); - assertThat(languageDriverRegistry.getDriver(ThymeleafLanguageDriver.class)).isNotNull(); + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisScanMapperConfiguration.class, + SingleLanguageDriverConfiguration.class, PropertyPlaceholderAutoConfiguration.class) + .withPropertyValues( + "spring.autoconfigure.exclude:org.mybatis.spring.boot.autoconfigure.MybatisLanguageDriverAutoConfiguration") + .run(context -> { + SqlSessionFactory sqlSessionFactory = context.getBean(SqlSessionFactory.class); + LanguageDriverRegistry languageDriverRegistry = sqlSessionFactory.getConfiguration().getLanguageRegistry(); + assertThat(context.getBeanNamesForType(LanguageDriver.class)).hasSize(1); + assertThat(languageDriverRegistry.getDefaultDriverClass()).isEqualTo(ThymeleafLanguageDriver.class); + assertThat(languageDriverRegistry.getDefaultDriver()).isInstanceOf(ThymeleafLanguageDriver.class); + assertThat(languageDriverRegistry.getDriver(ThymeleafLanguageDriver.class)).isNotNull(); + }); } @Test void testMybatisLanguageDriverAutoConfigurationWithSingleCandidateWhenDefaultLanguageDriverIsSpecify() { - TestPropertyValues - .of("mybatis.default-scripting-language-driver:org.apache.ibatis.scripting.xmltags.XMLLanguageDriver", + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisScanMapperConfiguration.class, + SingleLanguageDriverConfiguration.class, PropertyPlaceholderAutoConfiguration.class) + .withPropertyValues( + "mybatis.default-scripting-language-driver:org.apache.ibatis.scripting.xmltags.XMLLanguageDriver", "spring.autoconfigure.exclude:org.mybatis.spring.boot.autoconfigure.MybatisLanguageDriverAutoConfiguration") - .applyTo(this.context); - this.context.register(EmbeddedDataSourceConfiguration.class, MybatisScanMapperConfiguration.class, - SingleLanguageDriverConfiguration.class, MybatisAutoConfiguration.class, - PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - SqlSessionFactory sqlSessionFactory = this.context.getBean(SqlSessionFactory.class); - LanguageDriverRegistry languageDriverRegistry = sqlSessionFactory.getConfiguration().getLanguageRegistry(); - assertThat(this.context.getBeanNamesForType(LanguageDriver.class)).hasSize(1); - assertThat(languageDriverRegistry.getDefaultDriverClass()).isEqualTo(XMLLanguageDriver.class); - assertThat(languageDriverRegistry.getDefaultDriver()).isInstanceOf(XMLLanguageDriver.class); - assertThat(languageDriverRegistry.getDriver(ThymeleafLanguageDriver.class)).isNotNull(); + .run(context -> { + SqlSessionFactory sqlSessionFactory = context.getBean(SqlSessionFactory.class); + LanguageDriverRegistry languageDriverRegistry = sqlSessionFactory.getConfiguration().getLanguageRegistry(); + assertThat(context.getBeanNamesForType(LanguageDriver.class)).hasSize(1); + assertThat(languageDriverRegistry.getDefaultDriverClass()).isEqualTo(XMLLanguageDriver.class); + assertThat(languageDriverRegistry.getDefaultDriver()).isInstanceOf(XMLLanguageDriver.class); + assertThat(languageDriverRegistry.getDriver(ThymeleafLanguageDriver.class)).isNotNull(); + }); + } + + @Test + void whenFlywayIsAutoConfiguredThenMybatisSqlSessionTemplateDependsOnFlywayBeans() { + ApplicationContextRunner contextRunner = new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(FlywayAutoConfiguration.class, MybatisAutoConfiguration.class)); + contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class).run((context) -> { + BeanDefinition beanDefinition = context.getBeanFactory().getBeanDefinition("sqlSessionTemplate"); + assertThat(beanDefinition.getDependsOn()).containsExactlyInAnyOrder("flywayInitializer", "flyway"); + }); + } + + @Test + void whenCustomMigrationInitializerIsDefinedThenMybatisSqlSessionTemplateDependsOnIt() { + ApplicationContextRunner contextRunner = new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(FlywayAutoConfiguration.class, MybatisAutoConfiguration.class)); + contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, CustomFlywayMigrationInitializer.class) + .run((context) -> { + BeanDefinition beanDefinition = context.getBeanFactory().getBeanDefinition("sqlSessionTemplate"); + assertThat(beanDefinition.getDependsOn()).containsExactlyInAnyOrder("flywayMigrationInitializer", "flyway"); + }); + } + + @Test + void whenCustomFlywayIsDefinedThenMybatisSqlSessionTemplateDependsOnIt() { + ApplicationContextRunner contextRunner = new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(FlywayAutoConfiguration.class, MybatisAutoConfiguration.class)); + contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, CustomFlyway.class).run((context) -> { + BeanDefinition beanDefinition = context.getBeanFactory().getBeanDefinition("sqlSessionTemplate"); + assertThat(beanDefinition.getDependsOn()).containsExactlyInAnyOrder("customFlyway"); + }); + } + + @Test + void whenLiquibaseIsAutoConfiguredThenMybatisSqlSessionTemplateDependsOnSpringLiquibaseBeans() { + ApplicationContextRunner contextRunner = new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(LiquibaseAutoConfiguration.class, MybatisAutoConfiguration.class)); + contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class).run((context) -> { + BeanDefinition beanDefinition = context.getBeanFactory().getBeanDefinition("sqlSessionTemplate"); + assertThat(beanDefinition.getDependsOn()).containsExactly("liquibase"); + }); + } + + @Test + void whenCustomSpringLiquibaseIsDefinedThenMybatisSqlSessionTemplateDependsOnSpringLiquibaseBeans() { + ApplicationContextRunner contextRunner = new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(LiquibaseAutoConfiguration.class, MybatisAutoConfiguration.class)); + contextRunner.withUserConfiguration(LiquibaseUserConfiguration.class, EmbeddedDataSourceConfiguration.class) + .run((context) -> { + BeanDefinition beanDefinition = context.getBeanFactory().getBeanDefinition("sqlSessionTemplate"); + assertThat(beanDefinition.getDependsOn()).containsExactly("springLiquibase"); + }); + } + + @Test + void testTypeAliasesWithMultiByteCharacterInPackageName() { + this.contextRunner + .withUserConfiguration(EmbeddedDataSourceConfiguration.class, MybatisBootMapperScanAutoConfiguration.class) + .withPropertyValues("mybatis.config-location:mybatis-config2.xml").run(context -> { + org.apache.ibatis.session.Configuration configuration = context.getBean(SqlSessionFactory.class) + .getConfiguration(); + assertThat(configuration.getTypeAliasRegistry().getTypeAliases()).containsKey("シティー"); + }); } @Configuration @@ -846,13 +900,11 @@ DataSource dataSourceReplica() { } @Configuration - @EnableAutoConfiguration @MapperScan(basePackages = "com.example.mapper", lazyInitialization = "${mybatis.lazy-initialization:false}") static class MybatisScanMapperConfiguration { } @Configuration - @EnableAutoConfiguration static class MapperFactoryBeanConfiguration { @Bean MapperFactoryBean dateTimeMapper(SqlSessionFactory sqlSessionFactory) { @@ -863,7 +915,6 @@ MapperFactoryBean dateTimeMapper(SqlSessionFactory sqlSessionFac } @Configuration - @EnableAutoConfiguration static class MapperScannerConfigurerConfiguration { @Bean static MapperScannerConfigurer mapperScannerConfigurer() { @@ -874,7 +925,6 @@ static MapperScannerConfigurer mapperScannerConfigurer() { } @Configuration - @EnableAutoConfiguration static class MybatisBootMapperScanAutoConfiguration implements BeanFactoryPostProcessor { @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { @@ -883,7 +933,6 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) } @Configuration - @EnableAutoConfiguration static class MybatisMapperConfiguration { @Bean @@ -894,7 +943,6 @@ public CityMapperImpl cityMapper() { } @Configuration - @EnableAutoConfiguration static class MybatisInterceptorConfiguration { @Bean @@ -912,7 +960,6 @@ public MyInterceptor2 myInterceptor2() { } @Configuration - @EnableAutoConfiguration static class MybatisInterceptorConfiguration2 { @Bean @@ -930,7 +977,6 @@ public MyInterceptor2 myInterceptor2() { } @Configuration - @EnableAutoConfiguration static class MybatisTypeHandlerConfiguration { @Bean @@ -941,16 +987,6 @@ public MyTypeHandler myTypeHandler() { } @Configuration - @EnableAutoConfiguration - static class MybatisPropertiesConfigurationCustomizer { - @Autowired - void customize(MybatisProperties properties) { - properties.getConfiguration().getTypeHandlerRegistry().register(new DummyTypeHandler()); - } - } - - @Configuration - @EnableAutoConfiguration static class MyBatisConfigurationCustomizerConfiguration { @Bean ConfigurationCustomizer typeHandlerConfigurationCustomizer() { @@ -964,7 +1000,6 @@ ConfigurationCustomizer cacheConfigurationCustomizer() { } @Configuration - @EnableAutoConfiguration static class SqlSessionFactoryBeanCustomizerConfiguration { @Bean SqlSessionFactoryBeanCustomizer typeHandlerSqlSessionFactoryBeanCustomizer() { @@ -1039,7 +1074,8 @@ public PropertiesFactoryBean vendorProperties() { } @Bean - public VendorDatabaseIdProvider vendorDatabaseIdProvider(Properties vendorProperties) { + public VendorDatabaseIdProvider vendorDatabaseIdProvider( + @Qualifier("vendorProperties") Properties vendorProperties) { VendorDatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider(); databaseIdProvider.setProperties(vendorProperties); return databaseIdProvider; @@ -1123,4 +1159,46 @@ public UUID getNullableResult(CallableStatement cs, int columnIndex) { } + @Configuration + @TestAutoConfigurationPackage(CityMapper.class) + static class CityMapperRepositoryConfiguration { + + } + + @Configuration(proxyBeanMethods = false) + static class CustomFlywayMigrationInitializer { + + @Bean + FlywayMigrationInitializer flywayMigrationInitializer(Flyway flyway) { + FlywayMigrationInitializer initializer = new FlywayMigrationInitializer(flyway); + initializer.setOrder(Ordered.HIGHEST_PRECEDENCE); + return initializer; + } + + } + + @Configuration(proxyBeanMethods = false) + static class CustomFlyway { + + @Bean + Flyway customFlyway() { + return Flyway.configure().load(); + } + + } + + @Configuration(proxyBeanMethods = false) + static class LiquibaseUserConfiguration { + + @Bean + SpringLiquibase springLiquibase(DataSource dataSource) { + SpringLiquibase liquibase = new SpringLiquibase(); + liquibase.setChangeLog("classpath:/db/changelog/db.changelog-master.yaml"); + liquibase.setShouldRun(true); + liquibase.setDataSource(dataSource); + return liquibase; + } + + } + } diff --git a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/MybatisLanguageDriverAutoConfigurationTest.java b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/MybatisLanguageDriverAutoConfigurationTest.java index b1e50360..dfee682d 100644 --- a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/MybatisLanguageDriverAutoConfigurationTest.java +++ b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/MybatisLanguageDriverAutoConfigurationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -45,9 +45,9 @@ import org.mybatis.scripting.velocity.VelocityFacade; import org.mybatis.scripting.velocity.VelocityLanguageDriver; import org.mybatis.scripting.velocity.VelocityLanguageDriverConfig; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.util.TestPropertyValues; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.boot.autoconfigure.AutoConfigurations; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.thymeleaf.TemplateEngine; @@ -55,180 +55,172 @@ * Tests for {@link MybatisLanguageDriverAutoConfiguration}. * * @author Kazuki Shimizu + * @author Eddú Meléndez */ class MybatisLanguageDriverAutoConfigurationTest { - private AnnotationConfigApplicationContext context; + private ApplicationContextRunner contextRunner = new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(MybatisLanguageDriverAutoConfiguration.class)); @BeforeEach - void init() { - VelocityFacade.destroy(); - this.context = new AnnotationConfigApplicationContext(); - } - @AfterEach - void closeContext() { - if (this.context != null) { - this.context.close(); - } + void initializeVelocity() { VelocityFacade.destroy(); } @Test void testDefaultConfiguration() { - this.context.register(MybatisLanguageDriverAutoConfiguration.class); - this.context.refresh(); - Map languageDriverBeans = this.context.getBeansOfType(LanguageDriver.class); - assertThat(languageDriverBeans).hasSize(3).containsKeys("freeMarkerLanguageDriver", "velocityLanguageDriver", - "thymeleafLanguageDriver"); - assertThat(languageDriverBeans.get("freeMarkerLanguageDriver")).isInstanceOf(FreeMarkerLanguageDriver.class); - assertThat(languageDriverBeans.get("velocityLanguageDriver")).isInstanceOf(VelocityLanguageDriver.class); - assertThat(languageDriverBeans.get("thymeleafLanguageDriver")).isInstanceOf(ThymeleafLanguageDriver.class); - { - ThymeleafLanguageDriverConfig config = this.context.getBean(ThymeleafLanguageDriverConfig.class); - assertThat(config.isUse2way()).isEqualTo(true); - assertThat(config.getDialect().getPrefix()).isEqualTo("mb"); - assertThat(config.getDialect().getLikeAdditionalEscapeTargetChars()).isNull(); - assertThat(config.getDialect().getLikeEscapeChar()).isEqualTo('\\'); - assertThat(config.getDialect().getLikeEscapeClauseFormat()).isEqualTo("ESCAPE '%s'"); - assertThat(config.getTemplateFile().getBaseDir()).isEqualTo(""); - assertThat(config.getTemplateFile().getCacheTtl()).isNull(); - assertThat(config.getTemplateFile().getEncoding()).isEqualTo(StandardCharsets.UTF_8); - assertThat(config.getTemplateFile().getPatterns()).hasSize(1).contains("*.sql"); - assertThat(config.getCustomizer()).isNull(); - } - { - FreeMarkerLanguageDriverConfig config = this.context.getBean(FreeMarkerLanguageDriverConfig.class); - assertThat(config.getBasePackage()).isEqualTo(""); - assertThat(config.getFreemarkerSettings()).isEmpty(); - } - { - VelocityLanguageDriverConfig config = this.context.getBean(VelocityLanguageDriverConfig.class); + this.contextRunner.run(context -> { + Map languageDriverBeans = context.getBeansOfType(LanguageDriver.class); + assertThat(languageDriverBeans).hasSize(3).containsKeys("freeMarkerLanguageDriver", "velocityLanguageDriver", + "thymeleafLanguageDriver"); + assertThat(languageDriverBeans.get("freeMarkerLanguageDriver")).isInstanceOf(FreeMarkerLanguageDriver.class); + assertThat(languageDriverBeans.get("velocityLanguageDriver")).isInstanceOf(VelocityLanguageDriver.class); + assertThat(languageDriverBeans.get("thymeleafLanguageDriver")).isInstanceOf(ThymeleafLanguageDriver.class); + + ThymeleafLanguageDriverConfig thymeleafLanguageDriverConfig = context + .getBean(ThymeleafLanguageDriverConfig.class); + assertThat(thymeleafLanguageDriverConfig.isUse2way()).isTrue(); + assertThat(thymeleafLanguageDriverConfig.getDialect().getPrefix()).isEqualTo("mb"); + assertThat(thymeleafLanguageDriverConfig.getDialect().getLikeAdditionalEscapeTargetChars()).isNull(); + assertThat(thymeleafLanguageDriverConfig.getDialect().getLikeEscapeChar()).isEqualTo('\\'); + assertThat(thymeleafLanguageDriverConfig.getDialect().getLikeEscapeClauseFormat()).isEqualTo("ESCAPE '%s'"); + assertThat(thymeleafLanguageDriverConfig.getTemplateFile().getBaseDir()).isEmpty(); + assertThat(thymeleafLanguageDriverConfig.getTemplateFile().getCacheTtl()).isNull(); + assertThat(thymeleafLanguageDriverConfig.getTemplateFile().getEncoding()).isEqualTo(StandardCharsets.UTF_8); + assertThat(thymeleafLanguageDriverConfig.getTemplateFile().getPatterns()).hasSize(1).contains("*.sql"); + assertThat(thymeleafLanguageDriverConfig.getCustomizer()).isNull(); + + FreeMarkerLanguageDriverConfig freeMarkerLanguageDriverConfig = context + .getBean(FreeMarkerLanguageDriverConfig.class); + assertThat(freeMarkerLanguageDriverConfig.getBasePackage()).isEmpty(); + assertThat(freeMarkerLanguageDriverConfig.getFreemarkerSettings()).isEmpty(); + + VelocityLanguageDriverConfig velocityLanguageDriverConfig = context.getBean(VelocityLanguageDriverConfig.class); @SuppressWarnings("deprecation") - String[] userDirective = config.getUserdirective(); - assertThat(userDirective).hasSize(0); - assertThat(config.getAdditionalContextAttributes()).hasSize(0); - assertThat(config.getVelocitySettings()).hasSize(2); - assertThat(config.getVelocitySettings().get(RuntimeConstants.RESOURCE_LOADERS)).isEqualTo("class"); - assertThat(config.getVelocitySettings().get(RuntimeConstants.RESOURCE_LOADER + ".class.class")) - .isEqualTo("org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); - assertThat(config.generateCustomDirectivesString()).isEqualTo( + String[] userDirective = velocityLanguageDriverConfig.getUserdirective(); + assertThat(userDirective).isEmpty(); + assertThat(velocityLanguageDriverConfig.getAdditionalContextAttributes()).isEmpty(); + assertThat(velocityLanguageDriverConfig.getVelocitySettings()).hasSize(2); + assertThat(velocityLanguageDriverConfig.getVelocitySettings()).containsEntry(RuntimeConstants.RESOURCE_LOADERS, + "class"); + assertThat(velocityLanguageDriverConfig.getVelocitySettings()).containsEntry( + RuntimeConstants.RESOURCE_LOADER + ".class.class", + "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); + assertThat(velocityLanguageDriverConfig.generateCustomDirectivesString()).isEqualTo( "org.mybatis.scripting.velocity.TrimDirective,org.mybatis.scripting.velocity.WhereDirective,org.mybatis.scripting.velocity.SetDirective,org.mybatis.scripting.velocity.InDirective,org.mybatis.scripting.velocity.RepeatDirective"); - } + }); } @Test void testCustomConfiguration() { - this.context.register(MyLanguageDriverConfig.class, MybatisLanguageDriverAutoConfiguration.class); - this.context.refresh(); - Map languageDriverBeans = this.context.getBeansOfType(LanguageDriver.class); - assertThat(languageDriverBeans).hasSize(3).containsKeys("myFreeMarkerLanguageDriver", "myVelocityLanguageDriver", - "myThymeleafLanguageDriver"); + this.contextRunner.withUserConfiguration(MyLanguageDriverConfig.class).run(context -> { + Map languageDriverBeans = context.getBeansOfType(LanguageDriver.class); + assertThat(languageDriverBeans).hasSize(3).containsKeys("myFreeMarkerLanguageDriver", "myVelocityLanguageDriver", + "myThymeleafLanguageDriver"); + }); } @Test @SuppressWarnings("deprecation") void testLegacyConfiguration() { - this.context.register(TestingLegacyFreeMarkerConfiguration.class, TestingLegacyVelocityConfiguration.class); - this.context.refresh(); - Map languageDriverBeans = this.context.getBeansOfType(LanguageDriver.class); - assertThat(languageDriverBeans).hasSize(2).containsKeys("freeMarkerLanguageDriver", "velocityLanguageDriver"); - assertThat(this.context.getBean(org.mybatis.scripting.velocity.Driver.class)).isNotNull(); - assertThat(this.context.getBean(FreeMarkerLanguageDriver.class)).isNotNull(); - assertThat(this.context.getBeanNamesForType(VelocityLanguageDriverConfig.class)).hasSize(0); - assertThat(this.context.getBeanNamesForType(FreeMarkerLanguageDriverConfig.class)).hasSize(0); + new ApplicationContextRunner() + .withUserConfiguration(TestingLegacyFreeMarkerConfiguration.class, TestingLegacyVelocityConfiguration.class) + .run(context -> { + Map languageDriverBeans = context.getBeansOfType(LanguageDriver.class); + assertThat(languageDriverBeans).hasSize(2).containsKeys("freeMarkerLanguageDriver", "velocityLanguageDriver"); + assertThat(context.getBean(org.mybatis.scripting.velocity.Driver.class)).isNotNull(); + assertThat(context.getBean(FreeMarkerLanguageDriver.class)).isNotNull(); + assertThat(context.getBeanNamesForType(VelocityLanguageDriverConfig.class)).isEmpty(); + assertThat(context.getBeanNamesForType(FreeMarkerLanguageDriverConfig.class)).isEmpty(); + }); } @Test void testCustomThymeleafConfig() { - this.context.register(ThymeleafCustomLanguageDriverConfig.class, MybatisLanguageDriverAutoConfiguration.class); - this.context.refresh(); - ThymeleafLanguageDriver driver = this.context.getBean(ThymeleafLanguageDriver.class); - SqlSource sqlSource = driver.createSqlSource(new Configuration(), - "SELECT * FROM users WHERE id = /*[# m:p='id']*/ 1 /*[/]*/", Integer.class); - BoundSql boundSql = sqlSource.getBoundSql(10); - assertThat(boundSql.getSql()).isEqualTo("SELECT * FROM users WHERE id = ?"); - assertThat(boundSql.getParameterObject()).isEqualTo(10); - assertThat(boundSql.getParameterMappings().get(0).getProperty()).isEqualTo("id"); - assertThat(boundSql.getParameterMappings().get(0).getJavaType()).isEqualTo(Integer.class); - ThymeleafLanguageDriverConfig config = this.context.getBean(ThymeleafLanguageDriverConfig.class); - assertThat(config.isUse2way()).isEqualTo(true); - assertThat(config.getDialect().getPrefix()).isEqualTo("m"); - assertThat(config.getDialect().getLikeAdditionalEscapeTargetChars()).isNull(); - assertThat(config.getDialect().getLikeEscapeChar()).isEqualTo('\\'); - assertThat(config.getDialect().getLikeEscapeClauseFormat()).isEqualTo("ESCAPE '%s'"); - assertThat(config.getTemplateFile().getBaseDir()).isEqualTo(""); - assertThat(config.getTemplateFile().getCacheTtl()).isNull(); - assertThat(config.getTemplateFile().getEncoding()).isEqualTo(StandardCharsets.UTF_8); - assertThat(config.getTemplateFile().getPatterns()).hasSize(1).contains("*.sql"); - assertThat(config.getCustomizer()).isNull(); - } - - @Test - void test() { - this.context.register(FreeMarkerCustomLanguageDriverConfig.class, MybatisLanguageDriverAutoConfiguration.class); - this.context.refresh(); + this.contextRunner.withUserConfiguration(ThymeleafCustomLanguageDriverConfig.class).run(context -> { + ThymeleafLanguageDriver driver = context.getBean(ThymeleafLanguageDriver.class); + SqlSource sqlSource = driver.createSqlSource(new Configuration(), + "SELECT * FROM users WHERE id = /*[# m:p='id']*/ 1 /*[/]*/", Integer.class); + BoundSql boundSql = sqlSource.getBoundSql(10); + assertThat(boundSql.getSql()).isEqualTo("SELECT * FROM users WHERE id = ?"); + assertThat(boundSql.getParameterObject()).isEqualTo(10); + assertThat(boundSql.getParameterMappings().get(0).getProperty()).isEqualTo("id"); + assertThat(boundSql.getParameterMappings().get(0).getJavaType()).isEqualTo(Integer.class); + ThymeleafLanguageDriverConfig config = context.getBean(ThymeleafLanguageDriverConfig.class); + assertThat(config.isUse2way()).isTrue(); + assertThat(config.getDialect().getPrefix()).isEqualTo("m"); + assertThat(config.getDialect().getLikeAdditionalEscapeTargetChars()).isNull(); + assertThat(config.getDialect().getLikeEscapeChar()).isEqualTo('\\'); + assertThat(config.getDialect().getLikeEscapeClauseFormat()).isEqualTo("ESCAPE '%s'"); + assertThat(config.getTemplateFile().getBaseDir()).isEmpty(); + assertThat(config.getTemplateFile().getCacheTtl()).isNull(); + assertThat(config.getTemplateFile().getEncoding()).isEqualTo(StandardCharsets.UTF_8); + assertThat(config.getTemplateFile().getPatterns()).hasSize(1).contains("*.sql"); + assertThat(config.getCustomizer()).isNull(); + }); } @Test void testCustomFreeMarkerConfig() { - this.context.register(FreeMarkerCustomLanguageDriverConfig.class, MybatisLanguageDriverAutoConfiguration.class); - this.context.refresh(); - FreeMarkerLanguageDriver driver = this.context.getBean(FreeMarkerLanguageDriver.class); - @SuppressWarnings("unused") - class Param { - private Integer id; - private Integer version; - } - Param params = new Param(); - params.id = 10; - params.version = 20; - SqlSource sqlSource = driver.createSqlSource(new Configuration(), - "SELECT * FROM users WHERE id = #{id} and version = <@p name='version'/>", Param.class); - BoundSql boundSql = sqlSource.getBoundSql(params); - assertThat(boundSql.getSql()).isEqualTo("SELECT * FROM users WHERE id = ? and version = ?"); - assertThat(boundSql.getParameterMappings().get(0).getProperty()).isEqualTo("id"); - assertThat(boundSql.getParameterMappings().get(0).getJavaType()).isEqualTo(Integer.class); - assertThat(boundSql.getParameterMappings().get(1).getProperty()).isEqualTo("version"); - assertThat(boundSql.getParameterMappings().get(1).getJavaType()).isEqualTo(Integer.class); - FreeMarkerLanguageDriverConfig config = this.context.getBean(FreeMarkerLanguageDriverConfig.class); - assertThat(config.getBasePackage()).isEqualTo(""); - assertThat(config.getFreemarkerSettings()).hasSize(1); - assertThat(config.getFreemarkerSettings().get("interpolation_syntax")).isEqualTo("dollar"); + this.contextRunner.withUserConfiguration(FreeMarkerCustomLanguageDriverConfig.class).run(context -> { + FreeMarkerLanguageDriver driver = context.getBean(FreeMarkerLanguageDriver.class); + @SuppressWarnings("unused") + class Param { + private Integer id; + private Integer version; + } + Param params = new Param(); + params.id = 10; + params.version = 20; + SqlSource sqlSource = driver.createSqlSource(new Configuration(), + "SELECT * FROM users WHERE id = #{id} and version = <@p name='version'/>", Param.class); + BoundSql boundSql = sqlSource.getBoundSql(params); + assertThat(boundSql.getSql()).isEqualTo("SELECT * FROM users WHERE id = ? and version = ?"); + assertThat(boundSql.getParameterMappings().get(0).getProperty()).isEqualTo("id"); + assertThat(boundSql.getParameterMappings().get(0).getJavaType()).isEqualTo(Integer.class); + assertThat(boundSql.getParameterMappings().get(1).getProperty()).isEqualTo("version"); + assertThat(boundSql.getParameterMappings().get(1).getJavaType()).isEqualTo(Integer.class); + FreeMarkerLanguageDriverConfig config = context.getBean(FreeMarkerLanguageDriverConfig.class); + assertThat(config.getBasePackage()).isEmpty(); + assertThat(config.getFreemarkerSettings()).hasSize(1); + assertThat(config.getFreemarkerSettings()).containsEntry("interpolation_syntax", "dollar"); + }); } @Test void testCustomVelocityConfig() { - this.context.register(VelocityCustomLanguageDriverConfig.class, MybatisLanguageDriverAutoConfiguration.class); - this.context.refresh(); - VelocityLanguageDriver driver = this.context.getBean(VelocityLanguageDriver.class); - @SuppressWarnings("unused") - class Param { - private Integer id; - private Integer version; - } - Param params = new Param(); - params.id = 10; - params.version = 20; - SqlSource sqlSource = driver.createSqlSource(new Configuration(), "#now()", Param.class); - BoundSql boundSql = sqlSource.getBoundSql(params); - assertThat(boundSql.getSql()).isEqualTo("SELECT CURRENT_TIMESTAMP"); - VelocityLanguageDriverConfig config = this.context.getBean(VelocityLanguageDriverConfig.class); - @SuppressWarnings("deprecation") - String[] userDirective = config.getUserdirective(); - assertThat(userDirective).hasSize(0); - assertThat(config.getAdditionalContextAttributes()).hasSize(0); - assertThat(config.getVelocitySettings()).hasSize(3); - assertThat(config.getVelocitySettings().get(RuntimeConstants.RESOURCE_LOADERS)).isEqualTo("class"); - assertThat(config.getVelocitySettings().get(RuntimeConstants.RESOURCE_LOADER + ".class.class")) - .isEqualTo("org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); - assertThat(config.generateCustomDirectivesString()).isEqualTo(NowDirective.class.getName() - + ",org.mybatis.scripting.velocity.TrimDirective,org.mybatis.scripting.velocity.WhereDirective,org.mybatis.scripting.velocity.SetDirective,org.mybatis.scripting.velocity.InDirective,org.mybatis.scripting.velocity.RepeatDirective"); + this.contextRunner.withUserConfiguration(VelocityCustomLanguageDriverConfig.class).run(context -> { + VelocityLanguageDriver driver = context.getBean(VelocityLanguageDriver.class); + @SuppressWarnings("unused") + class Param { + private Integer id; + private Integer version; + } + Param params = new Param(); + params.id = 10; + params.version = 20; + SqlSource sqlSource = driver.createSqlSource(new Configuration(), "#now()", Param.class); + BoundSql boundSql = sqlSource.getBoundSql(params); + assertThat(boundSql.getSql()).isEqualTo("SELECT CURRENT_TIMESTAMP"); + VelocityLanguageDriverConfig config = context.getBean(VelocityLanguageDriverConfig.class); + @SuppressWarnings("deprecation") + String[] userDirective = config.getUserdirective(); + assertThat(userDirective).isEmpty(); + assertThat(config.getAdditionalContextAttributes()).isEmpty(); + assertThat(config.getVelocitySettings()).hasSize(3); + assertThat(config.getVelocitySettings()).containsEntry(RuntimeConstants.RESOURCE_LOADERS, "class"); + assertThat(config.getVelocitySettings()).containsEntry(RuntimeConstants.RESOURCE_LOADER + ".class.class", + "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); + assertThat(config.generateCustomDirectivesString()).isEqualTo(NowDirective.class.getName() + + ",org.mybatis.scripting.velocity.TrimDirective,org.mybatis.scripting.velocity.WhereDirective,org.mybatis.scripting.velocity.SetDirective,org.mybatis.scripting.velocity.InDirective,org.mybatis.scripting.velocity.RepeatDirective"); + }); } @Test void testCustomThymeleafConfigUsingConfigurationProperty() { - TestPropertyValues.of("mybatis.scripting-language-driver.thymeleaf.use2way=false", + this.contextRunner.withUserConfiguration(MyAutoConfiguration.class).withPropertyValues( + "mybatis.scripting-language-driver.thymeleaf.use2way=false", "mybatis.scripting-language-driver.thymeleaf.dialect.like-additional-escape-target-chars=*,?", "mybatis.scripting-language-driver.thymeleaf.dialect.like-escape-char=~", "mybatis.scripting-language-driver.thymeleaf.dialect.like-escape-clause-format=escape '%s'", @@ -244,121 +236,113 @@ void testCustomThymeleafConfigUsingConfigurationProperty() { "mybatis.scripting-language-driver.thymeleaf.template-file.path-provider.includes-mapper-name-when-separate-directory=false", "mybatis.scripting-language-driver.thymeleaf.template-file.path-provider.cache-enabled=false", "mybatis.scripting-language-driver.thymeleaf.customizer=org.mybatis.spring.boot.autoconfigure.MybatisLanguageDriverAutoConfigurationTest$MyTemplateEngineCustomizer") - .applyTo(this.context); - this.context.register(MyAutoConfiguration.class, MybatisLanguageDriverAutoConfiguration.class); - this.context.refresh(); - ThymeleafLanguageDriver driver = this.context.getBean(ThymeleafLanguageDriver.class); - SqlSource sqlSource = driver.createSqlSource(new Configuration(), - "SELECT * FROM users WHERE id = [# mybatis:p='id' /]", Integer.class); - BoundSql boundSql = sqlSource.getBoundSql(10); - assertThat(boundSql.getSql()).isEqualTo("SELECT * FROM users WHERE id = ?"); - assertThat(boundSql.getParameterObject()).isEqualTo(10); - assertThat(boundSql.getParameterMappings().get(0).getProperty()).isEqualTo("id"); - assertThat(boundSql.getParameterMappings().get(0).getJavaType()).isEqualTo(Integer.class); - ThymeleafLanguageDriverConfig config = this.context.getBean(ThymeleafLanguageDriverConfig.class); - assertThat(config.isUse2way()).isEqualTo(false); - assertThat(config.getDialect().getPrefix()).isEqualTo("mybatis"); - assertThat(config.getDialect().getLikeAdditionalEscapeTargetChars()).hasSize(2).contains('*', '?'); - assertThat(config.getDialect().getLikeEscapeChar()).isEqualTo('~'); - assertThat(config.getDialect().getLikeEscapeClauseFormat()).isEqualTo("escape '%s'"); - assertThat(config.getTemplateFile().getBaseDir()).isEqualTo("sqls"); - assertThat(config.getTemplateFile().getCacheTtl()).isEqualTo(1234); - assertThat(config.getTemplateFile().getEncoding()).isEqualTo(Charset.forName("Windows-31J")); - assertThat(config.getTemplateFile().getPatterns()).hasSize(2).contains("*.sql", "*.sqlf"); - assertThat(config.getTemplateFile().getPathProvider().getPrefix()).isEqualTo("sql/"); - assertThat(config.getTemplateFile().getPathProvider().isIncludesPackagePath()).isFalse(); - assertThat(config.getTemplateFile().getPathProvider().isSeparateDirectoryPerMapper()).isFalse(); - assertThat(config.getTemplateFile().getPathProvider().isIncludesMapperNameWhenSeparateDirectory()).isFalse(); - assertThat(config.getTemplateFile().getPathProvider().isCacheEnabled()).isFalse(); - assertThat(config.getCustomizer()).isEqualTo(MyTemplateEngineCustomizer.class); + .run(context -> { + ThymeleafLanguageDriver driver = context.getBean(ThymeleafLanguageDriver.class); + SqlSource sqlSource = driver.createSqlSource(new Configuration(), + "SELECT * FROM users WHERE id = [# mybatis:p='id' /]", Integer.class); + BoundSql boundSql = sqlSource.getBoundSql(10); + assertThat(boundSql.getSql()).isEqualTo("SELECT * FROM users WHERE id = ?"); + assertThat(boundSql.getParameterObject()).isEqualTo(10); + assertThat(boundSql.getParameterMappings().get(0).getProperty()).isEqualTo("id"); + assertThat(boundSql.getParameterMappings().get(0).getJavaType()).isEqualTo(Integer.class); + ThymeleafLanguageDriverConfig config = context.getBean(ThymeleafLanguageDriverConfig.class); + assertThat(config.isUse2way()).isFalse(); + assertThat(config.getDialect().getPrefix()).isEqualTo("mybatis"); + assertThat(config.getDialect().getLikeAdditionalEscapeTargetChars()).hasSize(2).contains('*', '?'); + assertThat(config.getDialect().getLikeEscapeChar()).isEqualTo('~'); + assertThat(config.getDialect().getLikeEscapeClauseFormat()).isEqualTo("escape '%s'"); + assertThat(config.getTemplateFile().getBaseDir()).isEqualTo("sqls"); + assertThat(config.getTemplateFile().getCacheTtl()).isEqualTo(1234); + assertThat(config.getTemplateFile().getEncoding()).isEqualTo(Charset.forName("Windows-31J")); + assertThat(config.getTemplateFile().getPatterns()).hasSize(2).contains("*.sql", "*.sqlf"); + assertThat(config.getTemplateFile().getPathProvider().getPrefix()).isEqualTo("sql/"); + assertThat(config.getTemplateFile().getPathProvider().isIncludesPackagePath()).isFalse(); + assertThat(config.getTemplateFile().getPathProvider().isSeparateDirectoryPerMapper()).isFalse(); + assertThat(config.getTemplateFile().getPathProvider().isIncludesMapperNameWhenSeparateDirectory()).isFalse(); + assertThat(config.getTemplateFile().getPathProvider().isCacheEnabled()).isFalse(); + assertThat(config.getCustomizer()).isEqualTo(MyTemplateEngineCustomizer.class); + }); } @Test void testCustomFreeMarkerConfigUsingConfigurationProperty() { - TestPropertyValues - .of("mybatis.scripting-language-driver.freemarker.base-package=sqls", + this.contextRunner.withUserConfiguration(MyAutoConfiguration.class) + .withPropertyValues("mybatis.scripting-language-driver.freemarker.base-package=sqls", "mybatis.scripting-language-driver.freemarker.freemarker-settings.interpolation_syntax=dollar", "mybatis.scripting-language-driver.freemarker.freemarker-settings.whitespace_stripping=yes") - .applyTo(this.context); - this.context.register(MyAutoConfiguration.class, MybatisLanguageDriverAutoConfiguration.class); - this.context.refresh(); - FreeMarkerLanguageDriver driver = this.context.getBean(FreeMarkerLanguageDriver.class); - @SuppressWarnings("unused") - class Param { - private Integer id; - private Integer version; - } - Param params = new Param(); - params.id = 10; - params.version = 20; - SqlSource sqlSource = driver.createSqlSource(new Configuration(), - "SELECT * FROM users WHERE id = #{id} and version = <@p name='version'/>", Param.class); - BoundSql boundSql = sqlSource.getBoundSql(params); - assertThat(boundSql.getSql()).isEqualTo("SELECT * FROM users WHERE id = ? and version = ?"); - assertThat(boundSql.getParameterMappings().get(0).getProperty()).isEqualTo("id"); - assertThat(boundSql.getParameterMappings().get(0).getJavaType()).isEqualTo(Integer.class); - assertThat(boundSql.getParameterMappings().get(1).getProperty()).isEqualTo("version"); - assertThat(boundSql.getParameterMappings().get(1).getJavaType()).isEqualTo(Integer.class); - FreeMarkerLanguageDriverConfig config = this.context.getBean(FreeMarkerLanguageDriverConfig.class); - assertThat(config.getBasePackage()).isEqualTo("sqls"); - assertThat(config.getFreemarkerSettings()).hasSize(2); - assertThat(config.getFreemarkerSettings().get("interpolation_syntax")).isEqualTo("dollar"); - assertThat(config.getFreemarkerSettings().get("whitespace_stripping")).isEqualTo("yes"); + .run(context -> { + FreeMarkerLanguageDriver driver = context.getBean(FreeMarkerLanguageDriver.class); + @SuppressWarnings("unused") + class Param { + private Integer id; + private Integer version; + } + Param params = new Param(); + params.id = 10; + params.version = 20; + SqlSource sqlSource = driver.createSqlSource(new Configuration(), + "SELECT * FROM users WHERE id = #{id} and version = <@p name='version'/>", Param.class); + BoundSql boundSql = sqlSource.getBoundSql(params); + assertThat(boundSql.getSql()).isEqualTo("SELECT * FROM users WHERE id = ? and version = ?"); + assertThat(boundSql.getParameterMappings().get(0).getProperty()).isEqualTo("id"); + assertThat(boundSql.getParameterMappings().get(0).getJavaType()).isEqualTo(Integer.class); + assertThat(boundSql.getParameterMappings().get(1).getProperty()).isEqualTo("version"); + assertThat(boundSql.getParameterMappings().get(1).getJavaType()).isEqualTo(Integer.class); + FreeMarkerLanguageDriverConfig config = context.getBean(FreeMarkerLanguageDriverConfig.class); + assertThat(config.getBasePackage()).isEqualTo("sqls"); + assertThat(config.getFreemarkerSettings()).hasSize(2); + assertThat(config.getFreemarkerSettings()).containsEntry("interpolation_syntax", "dollar"); + assertThat(config.getFreemarkerSettings()).containsEntry("whitespace_stripping", "yes"); + }); } @Test void testCustomVelocityConfigUsingConfigurationProperty() { - TestPropertyValues - .of("mybatis.scripting-language-driver.velocity.userdirective=" + NowDirective.class.getName(), + this.contextRunner.withUserConfiguration(MyAutoConfiguration.class) + .withPropertyValues("mybatis.scripting-language-driver.velocity.userdirective=" + NowDirective.class.getName(), "mybatis.scripting-language-driver.velocity.velocity-settings." + RuntimeConstants.INPUT_ENCODING + "=" + RuntimeConstants.ENCODING_DEFAULT, "mybatis.scripting-language-driver.velocity.additional-context-attributes.attribute1=java.lang.String", "mybatis.scripting-language-driver.velocity.additional-context-attributes.attribute2=java.util.HashMap") - .applyTo(this.context); - this.context.register(MyAutoConfiguration.class, MybatisLanguageDriverAutoConfiguration.class); - this.context.refresh(); - VelocityLanguageDriver driver = this.context.getBean(VelocityLanguageDriver.class); - @SuppressWarnings("unused") - class Param { - private Integer id; - private Integer version; - } - Param params = new Param(); - params.id = 10; - params.version = 20; - SqlSource sqlSource = driver.createSqlSource(new Configuration(), "#now()", Param.class); - BoundSql boundSql = sqlSource.getBoundSql(params); - assertThat(boundSql.getSql()).isEqualTo("SELECT CURRENT_TIMESTAMP"); - VelocityLanguageDriverConfig config = this.context.getBean(VelocityLanguageDriverConfig.class); - @SuppressWarnings("deprecation") - String[] userDirective = config.getUserdirective(); - assertThat(userDirective).hasSize(1).contains(NowDirective.class.getName()); - assertThat(config.getAdditionalContextAttributes()).hasSize(2); - assertThat(config.getAdditionalContextAttributes().get("attribute1")).isEqualTo("java.lang.String"); - assertThat(config.getAdditionalContextAttributes().get("attribute2")).isEqualTo("java.util.HashMap"); - assertThat(config.getVelocitySettings()).hasSize(3); - assertThat(config.getVelocitySettings().get(RuntimeConstants.RESOURCE_LOADERS)).isEqualTo("class"); - assertThat(config.getVelocitySettings().get(RuntimeConstants.RESOURCE_LOADER + ".class.class")) - .isEqualTo("org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); - assertThat(config.generateCustomDirectivesString()).isEqualTo(NowDirective.class.getName() - + ",org.mybatis.scripting.velocity.TrimDirective,org.mybatis.scripting.velocity.WhereDirective,org.mybatis.scripting.velocity.SetDirective,org.mybatis.scripting.velocity.InDirective,org.mybatis.scripting.velocity.RepeatDirective"); - assertThat(config.getVelocitySettings().get(RuntimeConstants.INPUT_ENCODING)) - .isEqualTo(RuntimeConstants.ENCODING_DEFAULT); - + .run(context -> { + VelocityLanguageDriver driver = context.getBean(VelocityLanguageDriver.class); + @SuppressWarnings("unused") + class Param { + private Integer id; + private Integer version; + } + Param params = new Param(); + params.id = 10; + params.version = 20; + SqlSource sqlSource = driver.createSqlSource(new Configuration(), "#now()", Param.class); + BoundSql boundSql = sqlSource.getBoundSql(params); + assertThat(boundSql.getSql()).isEqualTo("SELECT CURRENT_TIMESTAMP"); + VelocityLanguageDriverConfig config = context.getBean(VelocityLanguageDriverConfig.class); + @SuppressWarnings("deprecation") + String[] userDirective = config.getUserdirective(); + assertThat(userDirective).hasSize(1).contains(NowDirective.class.getName()); + assertThat(config.getAdditionalContextAttributes()).hasSize(2); + assertThat(config.getAdditionalContextAttributes()).containsEntry("attribute1", "java.lang.String"); + assertThat(config.getAdditionalContextAttributes()).containsEntry("attribute2", "java.util.HashMap"); + assertThat(config.getVelocitySettings()).hasSize(3); + assertThat(config.getVelocitySettings()).containsEntry(RuntimeConstants.RESOURCE_LOADERS, "class"); + assertThat(config.getVelocitySettings()).containsEntry(RuntimeConstants.RESOURCE_LOADER + ".class.class", + "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); + assertThat(config.generateCustomDirectivesString()).isEqualTo(NowDirective.class.getName() + + ",org.mybatis.scripting.velocity.TrimDirective,org.mybatis.scripting.velocity.WhereDirective,org.mybatis.scripting.velocity.SetDirective,org.mybatis.scripting.velocity.InDirective,org.mybatis.scripting.velocity.RepeatDirective"); + assertThat(config.getVelocitySettings()).containsEntry(RuntimeConstants.INPUT_ENCODING, + RuntimeConstants.ENCODING_DEFAULT); + }); } @Test void testExcludeMybatisLanguageDriverAutoConfiguration() { - TestPropertyValues - .of("spring.autoconfigure.exclude:org.mybatis.spring.boot.autoconfigure.MybatisLanguageDriverAutoConfiguration") - .applyTo(this.context); - this.context.register(MyAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBeanNamesForType(LanguageDriver.class)).hasSize(0); + new ApplicationContextRunner().withUserConfiguration(MyAutoConfiguration.class) + .run(context -> assertThat(context.getBeanNamesForType(LanguageDriver.class)).isEmpty()); } - @EnableAutoConfiguration - private static class MyAutoConfiguration { + @EnableConfigurationProperties + static class MyAutoConfiguration { } @org.springframework.context.annotation.Configuration @@ -371,7 +355,8 @@ static class TestingLegacyVelocityConfiguration extends MybatisLanguageDriverAutoConfiguration.LegacyVelocityConfiguration { } - private static class MyLanguageDriverConfig { + @org.springframework.context.annotation.Configuration + static class MyLanguageDriverConfig { @Bean FreeMarkerLanguageDriver myFreeMarkerLanguageDriver() { return new FreeMarkerLanguageDriver(); @@ -388,14 +373,16 @@ ThymeleafLanguageDriver myThymeleafLanguageDriver() { } } - private static class ThymeleafCustomLanguageDriverConfig { + @org.springframework.context.annotation.Configuration + static class ThymeleafCustomLanguageDriverConfig { @Bean ThymeleafLanguageDriverConfig thymeleafLanguageDriverConfig() { return ThymeleafLanguageDriverConfig.newInstance(c -> c.getDialect().setPrefix("m")); } } - private static class FreeMarkerCustomLanguageDriverConfig { + @org.springframework.context.annotation.Configuration + static class FreeMarkerCustomLanguageDriverConfig { @Bean FreeMarkerLanguageDriverConfig freeMarkerLanguageDriverConfig() { return FreeMarkerLanguageDriverConfig @@ -403,7 +390,8 @@ FreeMarkerLanguageDriverConfig freeMarkerLanguageDriverConfig() { } } - private static class VelocityCustomLanguageDriverConfig { + @org.springframework.context.annotation.Configuration + static class VelocityCustomLanguageDriverConfig { @Bean VelocityLanguageDriverConfig velocityLanguageDriverConfig() { return VelocityLanguageDriverConfig.newInstance( diff --git a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/MybatisPropertiesTest.java b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/MybatisPropertiesTest.java index 9d3cadb9..4edcc951 100644 --- a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/MybatisPropertiesTest.java +++ b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/MybatisPropertiesTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2024 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -16,14 +16,39 @@ package org.mybatis.spring.boot.autoconfigure; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; +import java.beans.PropertyDescriptor; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; + +import org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl; +import org.apache.ibatis.mapping.ResultSetType; +import org.apache.ibatis.session.AutoMappingBehavior; +import org.apache.ibatis.session.AutoMappingUnknownColumnBehavior; +import org.apache.ibatis.session.Configuration; +import org.apache.ibatis.session.ExecutorType; +import org.apache.ibatis.session.LocalCacheScope; +import org.apache.ibatis.session.SqlSessionFactory; +import org.apache.ibatis.type.EnumOrdinalTypeHandler; +import org.apache.ibatis.type.EnumTypeHandler; +import org.apache.ibatis.type.JdbcType; import org.junit.jupiter.api.Test; +import org.springframework.beans.PropertyAccessorFactory; +import org.springframework.boot.autoconfigure.AutoConfigurations; +import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; /** * @author Eddú Meléndez */ class MybatisPropertiesTest { + private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(MybatisAutoConfiguration.class)); + @Test void emptyMapperLocations() { MybatisProperties properties = new MybatisProperties(); @@ -48,4 +73,196 @@ void twoLocationsWithOneIncorrectLocation() { assertThat(properties.resolveMapperLocations()).hasSize(1); } + @Test + void testWithDefaultCoreConfiguration() { + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class).run(context -> { + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isSafeRowBoundsEnabled()).isFalse(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isSafeResultHandlerEnabled()).isTrue(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isSafeResultHandlerEnabled()).isTrue(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isAggressiveLazyLoading()).isFalse(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isMultipleResultSetsEnabled()).isTrue(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isUseGeneratedKeys()).isFalse(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isUseColumnLabel()).isTrue(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isCacheEnabled()).isTrue(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isCallSettersOnNulls()).isFalse(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isUseActualParamName()).isTrue(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isReturnInstanceForEmptyRow()).isFalse(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isShrinkWhitespacesInSql()).isFalse(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isNullableOnForEach()).isFalse(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isArgNameBasedConstructorAutoMapping()) + .isFalse(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isLazyLoadingEnabled()).isFalse(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getDefaultStatementTimeout()).isNull(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getDefaultFetchSize()).isNull(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getLocalCacheScope()) + .isEqualTo(LocalCacheScope.SESSION); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getJdbcTypeForNull()) + .isEqualTo(JdbcType.OTHER); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getDefaultResultSetType()).isNull(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getDefaultExecutorType()) + .isEqualTo(ExecutorType.SIMPLE); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getAutoMappingBehavior()) + .isEqualTo(AutoMappingBehavior.PARTIAL); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getAutoMappingUnknownColumnBehavior()) + .isEqualTo(AutoMappingUnknownColumnBehavior.NONE); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getLogPrefix()).isNull(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getLazyLoadTriggerMethods()) + .isEqualTo(new HashSet<>(Arrays.asList("equals", "clone", "hashCode", "toString"))); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getLogImpl()).isNull(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getVfsImpl()) + .isEqualTo(SpringBootVFS.class); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getDefaultSqlProviderType()).isNull(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getTypeHandlerRegistry() + .getTypeHandler(JdbcType.class).getClass()).isEqualTo(EnumTypeHandler.class); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getConfigurationFactory()).isNull(); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getVariables()).hasToString("{}"); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getDatabaseId()).isNull(); + }); + } + + @Test + void testWithCustomizeCoreConfiguration() { + assertAll( + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.safe-row-bounds-enabled:true") + .run(context -> assertThat( + context.getBean(SqlSessionFactory.class).getConfiguration().isSafeRowBoundsEnabled()).isTrue()), + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.safe-result-handler-enabled:false") + .run(context -> assertThat( + context.getBean(SqlSessionFactory.class).getConfiguration().isSafeResultHandlerEnabled()).isFalse()), + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.safe-result-handler-enabled:false") + .run(context -> assertThat( + context.getBean(SqlSessionFactory.class).getConfiguration().isSafeResultHandlerEnabled()).isFalse()), + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.aggressive-lazy-loading:true") + .run(context -> assertThat( + context.getBean(SqlSessionFactory.class).getConfiguration().isAggressiveLazyLoading()).isTrue()), + // Since MyBatis 3.5.17, the return value of isMultipleResultSetsEnabled() is always true + // See https://github.com/mybatis/mybatis-3/pull/3238 + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.multiple-result-sets-enabled:false") + .run(context -> assertThat( + context.getBean(SqlSessionFactory.class).getConfiguration().isMultipleResultSetsEnabled()).isTrue()), + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.use-generated-keys:true") + .run(context -> assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isUseGeneratedKeys()) + .isTrue()), + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.use-column-label:false") + .run(context -> assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isUseColumnLabel()) + .isFalse()), + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.cache-enabled:false") + .run(context -> assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isCacheEnabled()) + .isFalse()), + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.call-setters-on-nulls:true") + .run(context -> assertThat( + context.getBean(SqlSessionFactory.class).getConfiguration().isCallSettersOnNulls()).isTrue()), + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.use-actual-paramName:false") + .run(context -> assertThat( + context.getBean(SqlSessionFactory.class).getConfiguration().isUseActualParamName()).isFalse()), + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.return-instance-for-empty-row:true") + .run(context -> assertThat( + context.getBean(SqlSessionFactory.class).getConfiguration().isReturnInstanceForEmptyRow()).isTrue()), + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.shrink-whitespaces-in-sql:true") + .run(context -> assertThat( + context.getBean(SqlSessionFactory.class).getConfiguration().isShrinkWhitespacesInSql()).isTrue()), + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.nullable-on-for-each:true").run( + context -> assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().isNullableOnForEach()) + .isTrue()), + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.arg-name-based-constructor-auto-mapping:true") + .run(context -> assertThat( + context.getBean(SqlSessionFactory.class).getConfiguration().isArgNameBasedConstructorAutoMapping()) + .isTrue()), + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues("mybatis.configuration.lazy-loading-enabled:true") + .run(context -> assertThat( + context.getBean(SqlSessionFactory.class).getConfiguration().isLazyLoadingEnabled()).isTrue()), + () -> this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class).withPropertyValues( + "mybatis.configuration.default-statement-timeout:2000", "mybatis.configuration.default-fetch-size:1000", + "mybatis.configuration.local-cache-scope:STATEMENT", "mybatis.configuration.jdbc-type-for-null:NULL", + "mybatis.configuration.default-result-set-type:FORWARD_ONLY", + "mybatis.configuration.default-executor-type:BATCH", "mybatis.configuration.auto-mapping-behavior:FULL", + "mybatis.configuration.auto-mapping-unknown-column-behavior:WARNING", + "mybatis.configuration.log-prefix:[SQL]", + "mybatis.configuration.lazy-Load-trigger-methods:equals,clone,hashCode,toString,toDumpString", + "mybatis.configuration.logImpl:org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl", + "mybatis.configuration.vfsImpl:org.mybatis.spring.boot.autoconfigure.MybatisPropertiesTest$MyVFS", + "mybatis.configuration.default-sql-provider-type:org.mybatis.spring.boot.autoconfigure.MybatisPropertiesTest$MySqlProvider", + "mybatis.configuration.defaultEnumTypeHandler:org.apache.ibatis.type.EnumOrdinalTypeHandler", + "mybatis.configuration.configuration-factory:org.mybatis.spring.boot.autoconfigure.MybatisPropertiesTest$MyConfigurationFactory", + "mybatis.configuration.variables.key1:value1", "mybatis.configuration.variables.key2:value2", + "mybatis.configuration.database-id:mysql").run(context -> { + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getDefaultStatementTimeout()) + .isEqualTo(2000); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getDefaultFetchSize()) + .isEqualTo(1000); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getLocalCacheScope()) + .isEqualTo(LocalCacheScope.STATEMENT); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getJdbcTypeForNull()) + .isEqualTo(JdbcType.NULL); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getDefaultResultSetType()) + .isEqualTo(ResultSetType.FORWARD_ONLY); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getDefaultExecutorType()) + .isEqualTo(ExecutorType.BATCH); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getAutoMappingBehavior()) + .isEqualTo(AutoMappingBehavior.FULL); + assertThat( + context.getBean(SqlSessionFactory.class).getConfiguration().getAutoMappingUnknownColumnBehavior()) + .isEqualTo(AutoMappingUnknownColumnBehavior.WARNING); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getLogPrefix()).isEqualTo("[SQL]"); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getLazyLoadTriggerMethods()) + .isEqualTo(new HashSet<>(Arrays.asList("equals", "clone", "hashCode", "toString", "toDumpString"))); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getLogImpl()) + .isEqualTo(JakartaCommonsLoggingImpl.class); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getVfsImpl()) + .isEqualTo(MyVFS.class); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getDefaultSqlProviderType()) + .isEqualTo(MySqlProvider.class); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getTypeHandlerRegistry() + .getTypeHandler(JdbcType.class).getClass()).isEqualTo(EnumOrdinalTypeHandler.class); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getConfigurationFactory()) + .isEqualTo(MyConfigurationFactory.class); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getVariables()) + .hasToString("{key1=value1, key2=value2}"); + assertThat(context.getBean(SqlSessionFactory.class).getConfiguration().getDatabaseId()) + .hasToString("mysql"); + })); + } + + @Test + void checkProperties() { + Set mybatisCoreConfigurationProperties = Arrays + .stream(PropertyAccessorFactory.forBeanPropertyAccess(new Configuration()).getPropertyDescriptors()) + .map(PropertyDescriptor::getName).collect(Collectors.toSet()); + Set mybatisSpringBootConfigurationProperties = Arrays.stream(PropertyAccessorFactory + .forBeanPropertyAccess(new MybatisProperties.CoreConfiguration()).getPropertyDescriptors()) + .map(PropertyDescriptor::getName).collect(Collectors.toSet()); + mybatisCoreConfigurationProperties.removeAll(mybatisSpringBootConfigurationProperties); + mybatisCoreConfigurationProperties.removeAll(Arrays.asList("reflectorFactory", "defaultScriptingLanguage", + "sqlFragments", "typeHandlerRegistry", "mapperRegistry", "interceptors", "cacheNames", "incompleteResultMaps", + "typeAliasRegistry", "incompleteMethods", "proxyFactory", "resultMaps", "defaultScriptingLanguageInstance", + "parameterMaps", "keyGenerators", "parameterMapNames", "caches", "mappedStatementNames", "objectWrapperFactory", + "objectFactory", "incompleteStatements", "resultMapNames", "defaultScriptingLanuageInstance", + "keyGeneratorNames", "environment", "mappedStatements", "languageRegistry", "incompleteCacheRefs")); + assertThat(mybatisCoreConfigurationProperties).isEmpty(); + } + + static class MyVFS extends SpringBootVFS { + } + + static class MySqlProvider { + } + + static class MyConfigurationFactory { + } + } diff --git a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/TestAutoConfigurationPackage.java b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/TestAutoConfigurationPackage.java new file mode 100644 index 00000000..814fba31 --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/TestAutoConfigurationPackage.java @@ -0,0 +1,40 @@ +/* + * Copyright 2015-2022 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.mybatis.spring.boot.autoconfigure; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.boot.autoconfigure.AutoConfigurationPackages; +import org.springframework.context.annotation.Import; + +/** + * Test annotation to configure the {@link AutoConfigurationPackages} to an arbitrary value. + * + * @author Eddú Meléndez + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Import(TestAutoConfigurationPackageRegistrar.class) +public @interface TestAutoConfigurationPackage { + + Class value(); + +} diff --git a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/TestAutoConfigurationPackageRegistrar.java b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/TestAutoConfigurationPackageRegistrar.java new file mode 100644 index 00000000..08da40bf --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/TestAutoConfigurationPackageRegistrar.java @@ -0,0 +1,39 @@ +/* + * Copyright 2015-2022 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.mybatis.spring.boot.autoconfigure; + +import org.springframework.beans.factory.support.BeanDefinitionRegistry; +import org.springframework.boot.autoconfigure.AutoConfigurationPackages; +import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; +import org.springframework.core.annotation.AnnotationAttributes; +import org.springframework.core.type.AnnotationMetadata; +import org.springframework.util.ClassUtils; + +/** + * {@link ImportBeanDefinitionRegistrar} to store the base package for tests. + * + * @author Eddú Meléndez + */ +public class TestAutoConfigurationPackageRegistrar implements ImportBeanDefinitionRegistrar { + + @Override + public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) { + AnnotationAttributes attributes = AnnotationAttributes + .fromMap(metadata.getAnnotationAttributes(TestAutoConfigurationPackage.class.getName(), true)); + AutoConfigurationPackages.register(registry, ClassUtils.getPackageName(attributes.getString("value"))); + } + +} diff --git a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/domain/City.java b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/domain/City.java index 99deb289..93bf38af 100644 --- a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/domain/City.java +++ b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/domain/City.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/domain/Domain.java b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/domain/Domain.java index 66c5b9e7..e75d3fd2 100644 --- a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/domain/Domain.java +++ b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/domain/Domain.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/domain/Name.java b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/domain/Name.java index a16e34f6..107575f1 100644 --- a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/domain/Name.java +++ b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/domain/Name.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/handler/AtomicNumberTypeHandler.java b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/handler/AtomicNumberTypeHandler.java index 36571b1b..2a148461 100644 --- a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/handler/AtomicNumberTypeHandler.java +++ b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/handler/AtomicNumberTypeHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/handler/DummyTypeHandler.java b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/handler/DummyTypeHandler.java index 4732657b..7e3d3732 100644 --- a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/handler/DummyTypeHandler.java +++ b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/handler/DummyTypeHandler.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/mapper/CityMapper.java b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/mapper/CityMapper.java index 33a10f62..4dfb4077 100644 --- a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/mapper/CityMapper.java +++ b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/mapper/CityMapper.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/repository/CityMapperImpl.java b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/repository/CityMapperImpl.java index c9547605..a2b9294d 100644 --- a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/repository/CityMapperImpl.java +++ b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/repository/CityMapperImpl.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git "a/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/\343\203\220\343\203\252\343\203\245\343\203\274\343\202\252\343\203\226\343\202\270\343\202\247\343\202\257\343\203\210/\343\202\267\343\203\206\343\202\243\343\203\274.java" "b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/\343\203\220\343\203\252\343\203\245\343\203\274\343\202\252\343\203\226\343\202\270\343\202\247\343\202\257\343\203\210/\343\202\267\343\203\206\343\202\243\343\203\274.java" new file mode 100644 index 00000000..a8e32ac8 --- /dev/null +++ "b/mybatis-spring-boot-autoconfigure/src/test/java/org/mybatis/spring/boot/autoconfigure/\343\203\220\343\203\252\343\203\245\343\203\274\343\202\252\343\203\226\343\202\270\343\202\247\343\202\257\343\203\210/\343\202\267\343\203\206\343\202\243\343\203\274.java" @@ -0,0 +1,20 @@ +/* + * Copyright 2015-2022 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.mybatis.spring.boot.autoconfigure.バリューオブジェクト; + +@SuppressWarnings("unused") +public class シティー { +} diff --git a/mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-city.yaml b/mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-city.yaml new file mode 100644 index 00000000..322f645c --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-city.yaml @@ -0,0 +1,53 @@ +# +# Copyright 2015-2022 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. +# + +databaseChangeLog: + - changeSet: + id: 1 + author: dsyer + changes: + - createSequence: + sequenceName: hibernate_sequence + - createTable: + tableName: city + columns: + - column: + name: id + type: bigint + autoIncrement: true + constraints: + primaryKey: true + nullable: false + - column: + name: name + type: varchar(50) + constraints: + nullable: false + - column: + name: state + type: varchar(50) + constraints: + nullable: false + - column: + name: country + type: varchar(50) + constraints: + nullable: false + - column: + name: map + type: varchar(50) + constraints: + nullable: true diff --git a/mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-master.yaml b/mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-master.yaml new file mode 100644 index 00000000..b1d46c06 --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-master.yaml @@ -0,0 +1,36 @@ +# +# Copyright 2015-2022 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. +# + +databaseChangeLog: + - changeSet: + id: 1 + author: marceloverdijk + changes: + - createTable: + tableName: customer + columns: + - column: + name: id + type: int + autoIncrement: true + constraints: + primaryKey: true + nullable: false + - column: + name: name + type: varchar(50) + constraints: + nullable: false diff --git a/mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.json b/mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.json new file mode 100644 index 00000000..acaa0e21 --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.json @@ -0,0 +1,39 @@ +{ + "databaseChangeLog": [ + { + "changeSet": { + "author": "awilkinson", + "id": "1", + "changes": [ + { + "createTable": { + "tableName": "customer", + "columns": [ + { + "column": { + "name": "id", + "type": "int", + "autoIncrement": true, + "constraints": { + "nullable": false, + "primaryKey": true + } + } + }, + { + "column": { + "name": "name", + "type": "varchar(50)", + "constraints": { + "nullable": false + } + } + } + ] + } + } + ] + } + } + ] +} diff --git a/mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.sql b/mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.sql new file mode 100644 index 00000000..e508eb73 --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.sql @@ -0,0 +1,24 @@ +-- +-- Copyright 2015-2023 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. +-- + +--liquibase formatted sql + +--changeset author:awilkinson + +CREATE TABLE customer ( + id int AUTO_INCREMENT NOT NULL PRIMARY KEY, + name varchar(50) NOT NULL +); diff --git a/mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.xml b/mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.xml new file mode 100644 index 00000000..fb63182b --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + diff --git a/mybatis-spring-boot-autoconfigure/src/test/resources/db/migration/V1__init.sql b/mybatis-spring-boot-autoconfigure/src/test/resources/db/migration/V1__init.sql new file mode 100644 index 00000000..8f1f877e --- /dev/null +++ b/mybatis-spring-boot-autoconfigure/src/test/resources/db/migration/V1__init.sql @@ -0,0 +1,17 @@ +-- +-- Copyright 2015-2022 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. +-- + +DROP TABLE IF EXISTS TEST; diff --git a/mybatis-spring-boot-autoconfigure/src/test/resources/logback-test.xml b/mybatis-spring-boot-autoconfigure/src/test/resources/logback-test.xml index febdddcb..048eddc6 100644 --- a/mybatis-spring-boot-autoconfigure/src/test/resources/logback-test.xml +++ b/mybatis-spring-boot-autoconfigure/src/test/resources/logback-test.xml @@ -1,13 +1,13 @@ + + + + + + diff --git a/mybatis-spring-boot-autoconfigure/src/test/resources/org/mybatis/spring/boot/autoconfigure/repository/CityMapper.xml b/mybatis-spring-boot-autoconfigure/src/test/resources/org/mybatis/spring/boot/autoconfigure/repository/CityMapper.xml index 08f542f0..742281fa 100644 --- a/mybatis-spring-boot-autoconfigure/src/test/resources/org/mybatis/spring/boot/autoconfigure/repository/CityMapper.xml +++ b/mybatis-spring-boot-autoconfigure/src/test/resources/org/mybatis/spring/boot/autoconfigure/repository/CityMapper.xml @@ -1,13 +1,13 @@ - + 4.0.0 org.mybatis.spring.boot mybatis-spring-boot-samples - 2.2.3-SNAPSHOT + 3.0.6-SNAPSHOT mybatis-spring-boot-sample-annotation jar diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/java/sample/mybatis/annotation/SampleAnnotationApplication.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/java/sample/mybatis/annotation/SampleAnnotationApplication.java index 580f7827..4ad9ae99 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/java/sample/mybatis/annotation/SampleAnnotationApplication.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/java/sample/mybatis/annotation/SampleAnnotationApplication.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/java/sample/mybatis/annotation/domain/City.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/java/sample/mybatis/annotation/domain/City.java index 5bf0896e..2957d27f 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/java/sample/mybatis/annotation/domain/City.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/java/sample/mybatis/annotation/domain/City.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/java/sample/mybatis/annotation/mapper/CityMapper.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/java/sample/mybatis/annotation/mapper/CityMapper.java index 8df45bd5..c90f43ac 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/java/sample/mybatis/annotation/mapper/CityMapper.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/java/sample/mybatis/annotation/mapper/CityMapper.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/resources/application.properties b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/resources/application.properties index e355af59..0d437535 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/resources/application.properties +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/resources/application.properties @@ -1,11 +1,11 @@ # -# Copyright 2015-2021 the original author or authors. +# Copyright 2015-2023 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 # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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, @@ -15,4 +15,4 @@ # logging.level.root=WARN -logging.level.sample.mybatis.annotation.mapper=TRACE \ No newline at end of file +logging.level.sample.mybatis.annotation.mapper=TRACE diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/resources/data.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/resources/data.sql index 4e42e5bc..ec1033b4 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/resources/data.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/resources/data.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2019 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/resources/schema.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/resources/schema.sql index c1ad2471..754fa57e 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/resources/schema.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/main/resources/schema.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2019 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/extensions/annotation/CaptureSystemOutput.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/extensions/annotation/CaptureSystemOutput.java index 4d42a4b5..ae486363 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/extensions/annotation/CaptureSystemOutput.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/extensions/annotation/CaptureSystemOutput.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2025 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -44,9 +44,8 @@ import org.junit.platform.commons.support.ReflectionSupport; /** - * {@code @CaptureSystemOutput} is a JUnit JUpiter extension for capturing output to {@code System.out} and + * {@code @CaptureSystemOutput} is a JUnit Jupiter extension for capturing output to {@code System.out} and * {@code System.err} with expectations supported via Hamcrest matchers. - * *

Example Usage

* *
@@ -66,16 +65,13 @@
  *     System.err.println("Printed to System.err!");
  * }
  * 
- * *

* Based on code from Spring Boot's OutputCapture * rule for JUnit 4 by Phillip Webb and Andy Wilkinson. - * *

* Borrowing source from Sam Brannen as listed online at spring and stackoverflow from here CaptureSystemOutput - * *

* Additional changes to Sam Brannen logic supplied by kazuki43zoo from here enhancement @@ -142,14 +138,11 @@ private Store getStore(ExtensionContext context) { /** * {@code OutputCapture} captures output to {@code System.out} and {@code System.err}. - * *

* To obtain an instance of {@code OutputCapture}, declare a parameter of type {@code OutputCapture} in a JUnit * Jupiter {@code @Test}, {@code @BeforeEach}, or {@code @AfterEach} method. - * *

* {@linkplain #expect Expectations} are supported via Hamcrest matchers. - * *

* To obtain all output to {@code System.out} and {@code System.err}, simply invoke {@link #toString()}. * @@ -192,7 +185,6 @@ private void flush() { /** * Verify that the captured output is matched by the supplied {@code matcher}. - * *

* Verification is performed after the test method has executed. * diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/SampleMybatisApplicationMainTest.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/SampleMybatisApplicationMainTest.java index 95de4a43..d315d5ec 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/SampleMybatisApplicationMainTest.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/SampleMybatisApplicationMainTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/SampleMybatisApplicationTest.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/SampleMybatisApplicationTest.java index 90d332ea..64f8d81e 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/SampleMybatisApplicationTest.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/SampleMybatisApplicationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/mapper/CityMapperTest.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/mapper/CityMapperTest.java index d8abbaaf..45bd8074 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/mapper/CityMapperTest.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/mapper/CityMapperTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -27,6 +27,7 @@ * Tests for {@link CityMapper}. * * @author wonwoo + * * @since 1.2.1 */ @MybatisTest diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/mapper/MapperTestApplication.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/mapper/MapperTestApplication.java index fea4fea4..4937ce6f 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/mapper/MapperTestApplication.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation/src/test/java/sample/mybatis/annotation/mapper/MapperTestApplication.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -25,6 +25,7 @@ * Here. * * @author Kazuki Shimizu + * * @since 1.2.1 */ @SpringBootApplication diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/LICENSE_HEADER b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/LICENSE_HEADER new file mode 100644 index 00000000..a81590a5 --- /dev/null +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/LICENSE_HEADER @@ -0,0 +1,13 @@ + Copyright ${license.git.copyrightYears} 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. diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/format.xml b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/format.xml index c31af4e1..6d9e588e 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/format.xml +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/format.xml @@ -1,13 +1,13 @@ - + 4.0.0 org.mybatis.spring.boot mybatis-spring-boot-samples - 2.2.3-SNAPSHOT + 3.0.6-SNAPSHOT mybatis-spring-boot-sample-freemarker-legacy jar @@ -37,7 +37,6 @@ org.mybatis.scripting mybatis-freemarker - 1.2.3 com.h2database diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/java/sample/mybatis/freemarker/legacy/SampleFreeMarkerApplication.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/java/sample/mybatis/freemarker/legacy/SampleFreeMarkerApplication.java index ad75e292..649b3444 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/java/sample/mybatis/freemarker/legacy/SampleFreeMarkerApplication.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/java/sample/mybatis/freemarker/legacy/SampleFreeMarkerApplication.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/java/sample/mybatis/freemarker/legacy/domain/City.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/java/sample/mybatis/freemarker/legacy/domain/City.java index 6c598b70..1850e9f7 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/java/sample/mybatis/freemarker/legacy/domain/City.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/java/sample/mybatis/freemarker/legacy/domain/City.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/java/sample/mybatis/freemarker/legacy/mapper/CityMapper.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/java/sample/mybatis/freemarker/legacy/mapper/CityMapper.java index d5f8a45e..88a1b2ce 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/java/sample/mybatis/freemarker/legacy/mapper/CityMapper.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/java/sample/mybatis/freemarker/legacy/mapper/CityMapper.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/application.properties b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/application.properties index 247d218e..e2e810ef 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/application.properties +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/application.properties @@ -1,11 +1,11 @@ # -# Copyright 2015-2021 the original author or authors. +# Copyright 2015-2022 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 # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/data.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/data.sql index 4e42e5bc..ec1033b4 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/data.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/data.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2019 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/mappers/CityMapper-findByState.ftl b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/mappers/CityMapper-findByState.ftl index e79b67d8..64d841af 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/mappers/CityMapper-findByState.ftl +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/mappers/CityMapper-findByState.ftl @@ -1,12 +1,12 @@ <#-- - Copyright 2015-2019 the original author or authors. + Copyright 2015-2022 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 - http://www.apache.org/licenses/LICENSE-2.0 + 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/mappers/CityMapper.xml b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/mappers/CityMapper.xml index 9bbd069d..8b329e96 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/mappers/CityMapper.xml +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker-legacy/src/main/resources/mappers/CityMapper.xml @@ -1,13 +1,13 @@ - + 4.0.0 org.mybatis.spring.boot mybatis-spring-boot-samples - 2.2.3-SNAPSHOT + 3.0.6-SNAPSHOT mybatis-spring-boot-sample-freemarker jar diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/java/sample/mybatis/freemarker/SampleFreeMarkerApplication.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/java/sample/mybatis/freemarker/SampleFreeMarkerApplication.java index 3f0cedd0..8be03878 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/java/sample/mybatis/freemarker/SampleFreeMarkerApplication.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/java/sample/mybatis/freemarker/SampleFreeMarkerApplication.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/java/sample/mybatis/freemarker/domain/City.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/java/sample/mybatis/freemarker/domain/City.java index aee314dd..90d4a903 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/java/sample/mybatis/freemarker/domain/City.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/java/sample/mybatis/freemarker/domain/City.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/java/sample/mybatis/freemarker/mapper/CityMapper.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/java/sample/mybatis/freemarker/mapper/CityMapper.java index f6db1288..5877f15f 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/java/sample/mybatis/freemarker/mapper/CityMapper.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/java/sample/mybatis/freemarker/mapper/CityMapper.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/application.properties b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/application.properties index 8602be7a..b9178c66 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/application.properties +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/application.properties @@ -1,11 +1,11 @@ # -# Copyright 2015-2021 the original author or authors. +# Copyright 2015-2023 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 # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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, @@ -22,4 +22,4 @@ mybatis.type-aliases-package=sample.mybatis.freemarker.domain mybatis.scripting-language-driver.freemarker.template-file.base-dir=mappers/ mybatis.scripting-language-driver.freemarker.template-file.path-provider.includes-package-path=false -mybatis.scripting-language-driver.freemarker.template-file.path-provider.separate-directory-per-mapper=false \ No newline at end of file +mybatis.scripting-language-driver.freemarker.template-file.path-provider.separate-directory-per-mapper=false diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/data.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/data.sql index 5ed39225..d45ec9f5 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/data.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/data.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2020 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/mappers/CityMapper-findByCountry.ftl b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/mappers/CityMapper-findByCountry.ftl index d82c3bfc..12c678d3 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/mappers/CityMapper-findByCountry.ftl +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/mappers/CityMapper-findByCountry.ftl @@ -1,12 +1,12 @@ <#-- - Copyright 2015-2020 the original author or authors. + Copyright 2015-2022 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 - http://www.apache.org/licenses/LICENSE-2.0 + 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/mappers/CityMapper-findByState.ftl b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/mappers/CityMapper-findByState.ftl index e79b67d8..64d841af 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/mappers/CityMapper-findByState.ftl +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/mappers/CityMapper-findByState.ftl @@ -1,12 +1,12 @@ <#-- - Copyright 2015-2019 the original author or authors. + Copyright 2015-2022 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 - http://www.apache.org/licenses/LICENSE-2.0 + 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/mappers/CityMapper.xml b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/mappers/CityMapper.xml index 6a3d393c..99042dae 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/mappers/CityMapper.xml +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-freemarker/src/main/resources/mappers/CityMapper.xml @@ -1,13 +1,13 @@ - + 4.0.0 org.mybatis.spring.boot mybatis-spring-boot-samples - 2.2.3-SNAPSHOT + 3.0.6-SNAPSHOT mybatis-spring-boot-sample-groovy jar mybatis-spring-boot-sample-groovy org.mybatis.spring.boot.sample.groovy - true + 5.0.1 + ${project.basedir}/src/main/groovy + ${project.basedir}/src/test/groovy + + + + + + org.apache.groovy + groovy-bom + ${groovy.version} + pom + import + + + + org.mybatis.spring.boot @@ -41,9 +57,18 @@ runtime - org.codehaus.groovy + org.apache.groovy groovy - 3.0.10 + + + org.apache.groovy + groovy-groovydoc + true + + + org.apache.groovy + groovy-docgenerator + true @@ -58,8 +83,19 @@ - ${project.basedir}/src/main/groovy - ${project.basedir}/src/test/groovy + + + + com.github.spotbugs + spotbugs-maven-plugin + ${spotbugs.plugin} + + + true + + + + org.springframework.boot @@ -76,7 +112,14 @@ org.codehaus.gmavenplus gmavenplus-plugin - 1.13.1 + 4.2.1 + + true + ${project.name} Groovy Documentation + ${project.reporting.outputDirectory}/gapidocs +

${project.name} Groovy Documentation
+
${project.name} Groovy Documentation
+ @@ -94,4 +137,46 @@ + + + + release + + + + org.codehaus.gmavenplus + gmavenplus-plugin + + + groovydocs + + generateStubs + generateTestStubs + groovydoc + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + groovydoc-jar + + jar + + package + + javadoc + ${project.reporting.outputDirectory}/gapidocs + + + + + + + + +
diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/groovy/sample/mybatis/groovy/SampleGroovyApplication.groovy b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/groovy/sample/mybatis/groovy/SampleGroovyApplication.groovy index ff9cccf2..2a21d942 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/groovy/sample/mybatis/groovy/SampleGroovyApplication.groovy +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/groovy/sample/mybatis/groovy/SampleGroovyApplication.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/groovy/sample/mybatis/groovy/domain/City.groovy b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/groovy/sample/mybatis/groovy/domain/City.groovy index cbb55031..45ac07b0 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/groovy/sample/mybatis/groovy/domain/City.groovy +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/groovy/sample/mybatis/groovy/domain/City.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2023 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -21,7 +21,7 @@ class City { String name String state String country - + @Override String toString() { return "${id},${name},${state},${country}" diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/groovy/sample/mybatis/groovy/mapper/CityMapper.groovy b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/groovy/sample/mybatis/groovy/mapper/CityMapper.groovy index 2f37f79e..48f59544 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/groovy/sample/mybatis/groovy/mapper/CityMapper.groovy +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/groovy/sample/mybatis/groovy/mapper/CityMapper.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2023 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -33,5 +33,5 @@ interface CityMapper { state = #{state} ''') City findByState(@Param("state") String state) - -} \ No newline at end of file + +} diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/resources/application.properties b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/resources/application.properties index 0a029c96..af92c5d7 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/resources/application.properties +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/resources/application.properties @@ -1,11 +1,11 @@ # -# Copyright 2015-2021 the original author or authors. +# Copyright 2015-2023 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 # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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, @@ -15,4 +15,4 @@ # logging.level.root=WARN -logging.level.sample.mybatis.groovy.mapper=TRACE \ No newline at end of file +logging.level.sample.mybatis.groovy.mapper=TRACE diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/resources/data.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/resources/data.sql index 4e42e5bc..ec1033b4 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/resources/data.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/resources/data.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2019 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/resources/schema.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/resources/schema.sql index c1ad2471..754fa57e 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/resources/schema.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/main/resources/schema.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2019 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/extensions/groovy/CaptureSystemOutput.groovy b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/extensions/groovy/CaptureSystemOutput.groovy index de4c60e7..961b8f98 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/extensions/groovy/CaptureSystemOutput.groovy +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/extensions/groovy/CaptureSystemOutput.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2025 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -37,7 +37,7 @@ import static org.hamcrest.MatcherAssert.assertThat import static org.hamcrest.Matchers.allOf /** - * {@code @CaptureSystemOutput} is a JUnit JUpiter extension for capturing output to {@code System.out} and + * {@code @CaptureSystemOutput} is a JUnit Jupiter extension for capturing output to {@code System.out} and * {@code System.err} with expectations supported via Hamcrest matchers. * *

Example Usage

@@ -82,18 +82,18 @@ import static org.hamcrest.Matchers.allOf @Retention(RUNTIME) @ExtendWith(CaptureSystemOutput.Extension.class) @interface CaptureSystemOutput { - + class Extension implements BeforeAllCallback, AfterAllCallback, AfterEachCallback, ParameterResolver { - + @Override void beforeAll(ExtensionContext context) { getOutputCapture(context).captureOutput() } - + void afterAll(ExtensionContext context) { getOutputCapture(context).releaseOutput() } - + @Override void afterEach(ExtensionContext context) { OutputCapture outputCapture = getOutputCapture(context) @@ -106,33 +106,33 @@ import static org.hamcrest.Matchers.allOf outputCapture.reset() } } - + @Override boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) { boolean isTestMethodLevel = extensionContext.getTestMethod().isPresent() boolean isOutputCapture = parameterContext.getParameter().getType() == OutputCapture.class return isTestMethodLevel && isOutputCapture } - + @Override Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) { return getOutputCapture(extensionContext) } - + private OutputCapture getOutputCapture(ExtensionContext context) { return getOrComputeIfAbsent(getStore(context), OutputCapture.class) } - + private V getOrComputeIfAbsent(Store store, Class type) { return store.getOrComputeIfAbsent(type, {x -> ReflectionSupport.newInstance(x)}, type) } - + private Store getStore(ExtensionContext context) { return context.getStore(Namespace.create(getClass())) } - + } - + /** * {@code OutputCapture} captures output to {@code System.out} and {@code System.err}. * @@ -151,15 +151,15 @@ import static org.hamcrest.Matchers.allOf * @author Sam Brannen */ static class OutputCapture { - + private final List> matchers = new ArrayList<>() - + private CaptureOutputStream captureOut - + private CaptureOutputStream captureErr - + private ByteArrayOutputStream copy - + void captureOutput() { this.copy = new ByteArrayOutputStream() this.captureOut = new CaptureOutputStream(System.out, this.copy) @@ -167,7 +167,7 @@ import static org.hamcrest.Matchers.allOf System.setOut(new PrintStream(this.captureOut)) System.setErr(new PrintStream(this.captureErr)) } - + void releaseOutput() { System.setOut(this.captureOut.getOriginal()) System.setErr(this.captureErr.getOriginal()) @@ -182,7 +182,7 @@ import static org.hamcrest.Matchers.allOf // ignore } } - + /** * Verify that the captured output is matched by the supplied {@code matcher}. * @@ -195,7 +195,7 @@ import static org.hamcrest.Matchers.allOf void expect(Matcher matcher) { this.matchers.add(matcher) } - + /** * Return all captured output to {@code System.out} and {@code System.err} as a single string. */ @@ -204,53 +204,53 @@ import static org.hamcrest.Matchers.allOf flush() return this.copy.toString() } - + void reset() { this.matchers.clear() this.copy.reset() } - + private static class CaptureOutputStream extends OutputStream { - + private final PrintStream original - + private final OutputStream copy - + CaptureOutputStream(PrintStream original, OutputStream copy) { this.original = original this.copy = copy } - + PrintStream getOriginal() { return this.original } - + @Override void write(int b) throws IOException { this.copy.write(b) this.original.write(b) this.original.flush() } - + @Override void write(byte[] b) throws IOException { write(b, 0, b.length) } - + @Override void write(byte[] b, int off, int len) throws IOException { this.copy.write(b, off, len) this.original.write(b, off, len) } - + @Override void flush() throws IOException { this.copy.flush() this.original.flush() } - + } - + } - + } diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/SampleMybatisApplicationMainTest.groovy b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/SampleMybatisApplicationMainTest.groovy index 91b976a5..f9e8134c 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/SampleMybatisApplicationMainTest.groovy +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/SampleMybatisApplicationMainTest.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/SampleMybatisApplicationTest.groovy b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/SampleMybatisApplicationTest.groovy index 3a177ab3..d9549f26 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/SampleMybatisApplicationTest.groovy +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/SampleMybatisApplicationTest.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/mapper/CityMapperTest.groovy b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/mapper/CityMapperTest.groovy index aff975f5..e3b10eca 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/mapper/CityMapperTest.groovy +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/mapper/CityMapperTest.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2023 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -21,10 +21,10 @@ import org.springframework.beans.factory.annotation.Autowired @MybatisTest class CityMapperTest { - + @Autowired CityMapper cityMapper - + @Test void findByState() { def city = cityMapper.findByState("CA"); @@ -33,5 +33,5 @@ class CityMapperTest { assert city.state == "CA" assert city.country == "US" } - + } diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/mapper/MapperTestApplication.groovy b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/mapper/MapperTestApplication.groovy index ae0ba04d..1961a0d7 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/mapper/MapperTestApplication.groovy +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy/src/test/groovy/sample/mybatis/groovy/mapper/MapperTestApplication.groovy @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/LICENSE_HEADER b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/LICENSE_HEADER new file mode 100644 index 00000000..a81590a5 --- /dev/null +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/LICENSE_HEADER @@ -0,0 +1,13 @@ + Copyright ${license.git.copyrightYears} 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. diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/format.xml b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/format.xml index c31af4e1..6d9e588e 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/format.xml +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/format.xml @@ -1,13 +1,13 @@ - + 4.0.0 org.mybatis.spring.boot mybatis-spring-boot-samples - 2.2.3-SNAPSHOT + 3.0.6-SNAPSHOT mybatis-spring-boot-sample-kotlin jar mybatis-spring-boot-sample-kotlin org.mybatis.spring.boot.sample.kotlin - 1.6.21 - 1.8 + 2.2.20 @@ -62,8 +61,6 @@ - ${project.basedir}/src/main/kotlin - ${project.basedir}/src/test/kotlin org.springframework.boot @@ -101,20 +98,52 @@ compile - compile compile + compile test-compile - test-compile test-compile + test-compile + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + + release + + + + org.jetbrains.dokka + dokka-maven-plugin + 2.0.0 + + javadoc + ${project.build.directory}/dokka/javadoc + + + + attach-dokka-javadoc + + javadoc + javadocJar + + package + + + + + + + + diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/kotlin/sample/mybatis/kotlin/SampleKotlinApplication.kt b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/kotlin/sample/mybatis/kotlin/SampleKotlinApplication.kt index db41fadb..c6327efe 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/kotlin/sample/mybatis/kotlin/SampleKotlinApplication.kt +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/kotlin/sample/mybatis/kotlin/SampleKotlinApplication.kt @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2023 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -33,4 +33,4 @@ class SampleKotlinApplication (private val cityMapper: CityMapper) : CommandLine fun main(args: Array) { runApplication(*args) -} \ No newline at end of file +} diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/kotlin/sample/mybatis/kotlin/domain/City.kt b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/kotlin/sample/mybatis/kotlin/domain/City.kt index a1d7fce9..31be53af 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/kotlin/sample/mybatis/kotlin/domain/City.kt +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/kotlin/sample/mybatis/kotlin/domain/City.kt @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2023 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -20,4 +20,4 @@ data class City( var name: String? = null, var state: String? = null, var country: String? = null -) \ No newline at end of file +) diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/kotlin/sample/mybatis/kotlin/mapper/CityMapper.kt b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/kotlin/sample/mybatis/kotlin/mapper/CityMapper.kt index 5323892c..7463e823 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/kotlin/sample/mybatis/kotlin/mapper/CityMapper.kt +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/kotlin/sample/mybatis/kotlin/mapper/CityMapper.kt @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2023 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -33,4 +33,4 @@ interface CityMapper { """) fun findByState(@Param("state") state: String): City -} \ No newline at end of file +} diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/resources/application.properties b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/resources/application.properties index da0b091c..81508e61 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/resources/application.properties +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/resources/application.properties @@ -1,11 +1,11 @@ # -# Copyright 2015-2021 the original author or authors. +# Copyright 2015-2022 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 # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/resources/data.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/resources/data.sql index 4e42e5bc..ec1033b4 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/resources/data.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/resources/data.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2019 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/resources/schema.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/resources/schema.sql index b6751f98..23cdbac4 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/resources/schema.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/main/resources/schema.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2019 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/extensions/kotlin/CaptureSystemOutput.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/extensions/kotlin/CaptureSystemOutput.java index 2e08f938..bacba207 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/extensions/kotlin/CaptureSystemOutput.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/extensions/kotlin/CaptureSystemOutput.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2025 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -44,9 +44,8 @@ import org.junit.platform.commons.support.ReflectionSupport; /** - * {@code @CaptureSystemOutput} is a JUnit JUpiter extension for capturing output to {@code System.out} and + * {@code @CaptureSystemOutput} is a JUnit Jupiter extension for capturing output to {@code System.out} and * {@code System.err} with expectations supported via Hamcrest matchers. - * *

Example Usage

* *
@@ -66,16 +65,13 @@
  *     System.err.println("Printed to System.err!");
  * }
  * 
- * *

* Based on code from Spring Boot's OutputCapture * rule for JUnit 4 by Phillip Webb and Andy Wilkinson. - * *

* Borrowing source from Sam Brannen as listed online at spring and stackoverflow from here CaptureSystemOutput - * *

* Additional changes to Sam Brannen logic supplied by kazuki43zoo from here enhancement @@ -142,14 +138,11 @@ private Store getStore(ExtensionContext context) { /** * {@code OutputCapture} captures output to {@code System.out} and {@code System.err}. - * *

* To obtain an instance of {@code OutputCapture}, declare a parameter of type {@code OutputCapture} in a JUnit * Jupiter {@code @Test}, {@code @BeforeEach}, or {@code @AfterEach} method. - * *

* {@linkplain #expect Expectations} are supported via Hamcrest matchers. - * *

* To obtain all output to {@code System.out} and {@code System.err}, simply invoke {@link #toString()}. * @@ -192,7 +185,6 @@ private void flush() { /** * Verify that the captured output is matched by the supplied {@code matcher}. - * *

* Verification is performed after the test method has executed. * diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/SampleMybatisApplicationMainTest.kt b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/SampleMybatisApplicationMainTest.kt index 83737ad5..82e90894 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/SampleMybatisApplicationMainTest.kt +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/SampleMybatisApplicationMainTest.kt @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2023 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -29,4 +29,4 @@ class SampleMybatisApplicationMainTest { assertThat(output).contains("City(id=1, name=San Francisco, state=CA, country=US)") } -} \ No newline at end of file +} diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/SampleMybatisApplicationTest.kt b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/SampleMybatisApplicationTest.kt index 104974b4..972ae5c8 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/SampleMybatisApplicationTest.kt +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/SampleMybatisApplicationTest.kt @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2023 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -30,4 +30,4 @@ class SampleMybatisApplicationTest { assertThat(output).contains("City(id=1, name=San Francisco, state=CA, country=US)") } -} \ No newline at end of file +} diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/mapper/CityMapperTest.kt b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/mapper/CityMapperTest.kt index 731e168b..77a91fd0 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/mapper/CityMapperTest.kt +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/mapper/CityMapperTest.kt @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/mapper/MapperTestApplication.kt b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/mapper/MapperTestApplication.kt index 5df05ce2..4ceb8dda 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/mapper/MapperTestApplication.kt +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin/src/test/kotlin/sample/mybatis/kotlin/mapper/MapperTestApplication.kt @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2023 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -18,4 +18,4 @@ package sample.mybatis.kotlin.mapper import org.springframework.boot.autoconfigure.SpringBootApplication @SpringBootApplication -class MapperTestApplication \ No newline at end of file +class MapperTestApplication diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/LICENSE_HEADER b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/LICENSE_HEADER new file mode 100644 index 00000000..a81590a5 --- /dev/null +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/LICENSE_HEADER @@ -0,0 +1,13 @@ + Copyright ${license.git.copyrightYears} 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. diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/format.xml b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/format.xml index c31af4e1..6d9e588e 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/format.xml +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/format.xml @@ -1,13 +1,13 @@ - + 4.0.0 org.mybatis.spring.boot mybatis-spring-boot-samples - 2.2.3-SNAPSHOT + 3.0.6-SNAPSHOT mybatis-spring-boot-sample-thymeleaf jar diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/java/sample/mybatis/thymeleaf/SampleThymeleafApplication.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/java/sample/mybatis/thymeleaf/SampleThymeleafApplication.java index 4ba09f22..8d1b75a1 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/java/sample/mybatis/thymeleaf/SampleThymeleafApplication.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/java/sample/mybatis/thymeleaf/SampleThymeleafApplication.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/java/sample/mybatis/thymeleaf/domain/City.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/java/sample/mybatis/thymeleaf/domain/City.java index 645c105a..5054802d 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/java/sample/mybatis/thymeleaf/domain/City.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/java/sample/mybatis/thymeleaf/domain/City.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/java/sample/mybatis/thymeleaf/mapper/CityMapper.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/java/sample/mybatis/thymeleaf/mapper/CityMapper.java index 837ee4b1..ede97e82 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/java/sample/mybatis/thymeleaf/mapper/CityMapper.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/java/sample/mybatis/thymeleaf/mapper/CityMapper.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/application.properties b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/application.properties index f791c9b0..73e544f4 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/application.properties +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/application.properties @@ -1,11 +1,11 @@ # -# Copyright 2015-2021 the original author or authors. +# Copyright 2015-2023 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 # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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, @@ -22,4 +22,4 @@ mybatis.type-aliases-package=sample.mybatis.thymeleaf.domain mybatis.scripting-language-driver.thymeleaf.template-file.base-dir=mappers/ mybatis.scripting-language-driver.thymeleaf.template-file.path-provider.includes-package-path=false -mybatis.scripting-language-driver.thymeleaf.template-file.path-provider.separate-directory-per-mapper=false \ No newline at end of file +mybatis.scripting-language-driver.thymeleaf.template-file.path-provider.separate-directory-per-mapper=false diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/data.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/data.sql index 5ed39225..d45ec9f5 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/data.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/data.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2020 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/mappers/CityMapper-findByCountry.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/mappers/CityMapper-findByCountry.sql index 9125b79a..a44cb5da 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/mappers/CityMapper-findByCountry.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/mappers/CityMapper-findByCountry.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2020 the original author or authors. +-- Copyright 2015-2023 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, @@ -19,4 +19,4 @@ select from city where - country = /*[# mb:p="country"]*/ 'US' /*[/]*/ \ No newline at end of file + country = /*[# mb:p="country"]*/ 'US' /*[/]*/ diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/mappers/CityMapper-findByState.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/mappers/CityMapper-findByState.sql index f38250d0..4e3b3cb6 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/mappers/CityMapper-findByState.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/mappers/CityMapper-findByState.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2019 the original author or authors. +-- Copyright 2015-2023 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, @@ -19,4 +19,4 @@ select from city where - state = /*[# mb:p="state"]*/ 'CA' /*[/]*/ \ No newline at end of file + state = /*[# mb:p="state"]*/ 'CA' /*[/]*/ diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/mappers/CityMapper.xml b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/mappers/CityMapper.xml index a0256eda..3f153630 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/mappers/CityMapper.xml +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-thymeleaf/src/main/resources/mappers/CityMapper.xml @@ -1,13 +1,13 @@ - + 4.0.0 org.mybatis.spring.boot mybatis-spring-boot-samples - 2.2.3-SNAPSHOT + 3.0.6-SNAPSHOT mybatis-spring-boot-sample-velocity-legacy jar @@ -37,7 +37,7 @@ org.mybatis.scripting mybatis-velocity - 2.1.1 + 2.3.0 com.h2database diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/java/sample/mybatis/velocity/legacy/SampleVelocityApplication.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/java/sample/mybatis/velocity/legacy/SampleVelocityApplication.java index 6a784876..2bab3aec 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/java/sample/mybatis/velocity/legacy/SampleVelocityApplication.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/java/sample/mybatis/velocity/legacy/SampleVelocityApplication.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/java/sample/mybatis/velocity/legacy/domain/City.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/java/sample/mybatis/velocity/legacy/domain/City.java index 9b826a8e..f59ac885 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/java/sample/mybatis/velocity/legacy/domain/City.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/java/sample/mybatis/velocity/legacy/domain/City.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/java/sample/mybatis/velocity/legacy/mapper/CityMapper.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/java/sample/mybatis/velocity/legacy/mapper/CityMapper.java index fe5ee39c..fc75ebfd 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/java/sample/mybatis/velocity/legacy/mapper/CityMapper.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/java/sample/mybatis/velocity/legacy/mapper/CityMapper.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/application.properties b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/application.properties index 64c2e9db..0cbd8382 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/application.properties +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/application.properties @@ -1,11 +1,11 @@ # -# Copyright 2015-2021 the original author or authors. +# Copyright 2015-2022 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 # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/data.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/data.sql index 4e42e5bc..ec1033b4 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/data.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/data.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2019 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/mappers/CityMapper-findByState.vm b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/mappers/CityMapper-findByState.vm index d7fcb162..bc8c6d66 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/mappers/CityMapper-findByState.vm +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/mappers/CityMapper-findByState.vm @@ -1,11 +1,11 @@ #* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2023 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -19,4 +19,4 @@ select from city where - state = @{state} \ No newline at end of file + state = @{state} diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/mappers/CityMapper.xml b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/mappers/CityMapper.xml index 0b9a9ed5..e56d29d4 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/mappers/CityMapper.xml +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity-legacy/src/main/resources/mappers/CityMapper.xml @@ -1,13 +1,13 @@ - + 4.0.0 org.mybatis.spring.boot mybatis-spring-boot-samples - 2.2.3-SNAPSHOT + 3.0.6-SNAPSHOT mybatis-spring-boot-sample-velocity jar diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/java/sample/mybatis/velocity/SampleVelocityApplication.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/java/sample/mybatis/velocity/SampleVelocityApplication.java index a1778a6f..d20d90d5 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/java/sample/mybatis/velocity/SampleVelocityApplication.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/java/sample/mybatis/velocity/SampleVelocityApplication.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/java/sample/mybatis/velocity/domain/City.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/java/sample/mybatis/velocity/domain/City.java index 3d5ad5af..e5997f12 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/java/sample/mybatis/velocity/domain/City.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/java/sample/mybatis/velocity/domain/City.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/java/sample/mybatis/velocity/mapper/CityMapper.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/java/sample/mybatis/velocity/mapper/CityMapper.java index c17e64cb..d20cee91 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/java/sample/mybatis/velocity/mapper/CityMapper.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/java/sample/mybatis/velocity/mapper/CityMapper.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/application.properties b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/application.properties index b57982e7..07e742d8 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/application.properties +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/application.properties @@ -1,11 +1,11 @@ # -# Copyright 2015-2021 the original author or authors. +# Copyright 2015-2022 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 # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/data.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/data.sql index 4e42e5bc..ec1033b4 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/data.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/data.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2019 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/mappers/CityMapper-findByState.vm b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/mappers/CityMapper-findByState.vm index d7fcb162..bc8c6d66 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/mappers/CityMapper-findByState.vm +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/mappers/CityMapper-findByState.vm @@ -1,11 +1,11 @@ #* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2023 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -19,4 +19,4 @@ select from city where - state = @{state} \ No newline at end of file + state = @{state} diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/mappers/CityMapper.xml b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/mappers/CityMapper.xml index 5d2e0fa6..9446cf69 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/mappers/CityMapper.xml +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-velocity/src/main/resources/mappers/CityMapper.xml @@ -1,13 +1,13 @@ - + 4.0.0 org.mybatis.spring.boot mybatis-spring-boot-samples - 2.2.3-SNAPSHOT + 3.0.6-SNAPSHOT mybatis-spring-boot-sample-war war mybatis-spring-boot-sample-war - 9 - 9.0.62 + 11 + 11.0.13 org.mybatis.spring.boot.sample.war @@ -46,6 +46,12 @@ org.springframework.boot spring-boot-starter-web + + + org.apache.logging.log4j + log4j-to-slf4j + + org.springframework.boot @@ -78,17 +84,19 @@ + org.apache.maven.plugins maven-war-plugin - 3.3.2 + 3.4.0 + org.apache.maven.plugins maven-failsafe-plugin - 3.0.0-M6 + 3.5.4 org.codehaus.cargo cargo-maven3-plugin - 1.9.11 + 1.10.23 @@ -96,22 +104,6 @@ org.codehaus.cargo cargo-maven3-plugin - - - start-container - pre-integration-test - - start - - - - stop-container - post-integration-test - - stop - - - @@ -125,10 +117,29 @@ https://archive.apache.org/dist/tomcat/tomcat-${tomcat.major.version}/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip + ${project.build.directory}/cargo/cargo.log + ${project.build.directory}/cargo/container.log + + + start-container + + start + + pre-integration-test + + + stop-container + + stop + + post-integration-test + + + org.apache.maven.plugins maven-failsafe-plugin diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/SampleWebApplication.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/SampleWebApplication.java index c0d3aa38..1a228c82 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/SampleWebApplication.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/SampleWebApplication.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/controller/CityRestController.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/controller/CityRestController.java index 1f98df6d..3d245243 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/controller/CityRestController.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/controller/CityRestController.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -34,7 +34,7 @@ public CityRestController(CityMapper cityMapper) { } @GetMapping("{state}") - City getCity(@PathVariable String state) { + City getCity(@PathVariable("state") String state) { return cityMapper.findByState(state); } diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/domain/City.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/domain/City.java index 2492115b..a3042948 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/domain/City.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/domain/City.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/mapper/CityMapper.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/mapper/CityMapper.java index 6bf227e3..195387b7 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/mapper/CityMapper.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/java/sample/mybatis/war/mapper/CityMapper.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/resources/application.properties b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/resources/application.properties index 99029b62..712c2d5b 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/resources/application.properties +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/resources/application.properties @@ -1,11 +1,11 @@ # -# Copyright 2015-2021 the original author or authors. +# Copyright 2015-2023 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 # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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, @@ -18,4 +18,4 @@ server.port=18080 server.servlet.context-path=/mybatis-spring-boot-sample-war logging.level.root=INFO -logging.level.sample.mybatis.war.mapper=TRACE \ No newline at end of file +logging.level.sample.mybatis.war.mapper=TRACE diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/resources/data.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/resources/data.sql index 4e42e5bc..ec1033b4 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/resources/data.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/resources/data.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2019 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/resources/schema.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/resources/schema.sql index c1ad2471..754fa57e 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/resources/schema.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/main/resources/schema.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2019 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/SampleMybatisApplicationIT.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/SampleMybatisApplicationIT.java index 3359bfcd..71735856 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/SampleMybatisApplicationIT.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/SampleMybatisApplicationIT.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/SampleMybatisApplicationTest.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/SampleMybatisApplicationTest.java index 1e2e36b7..18f6f780 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/SampleMybatisApplicationTest.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/SampleMybatisApplicationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/mapper/CityMapperTest.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/mapper/CityMapperTest.java index fdd8ef62..0ea8410c 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/mapper/CityMapperTest.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/mapper/CityMapperTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -27,6 +27,7 @@ * Tests for {@link CityMapper}. * * @author wonwoo + * * @since 1.2.1 */ @MybatisTest diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/mapper/MapperTestApplication.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/mapper/MapperTestApplication.java index 3db47d64..82ac52f3 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/mapper/MapperTestApplication.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-war/src/test/java/sample/mybatis/war/mapper/MapperTestApplication.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -25,6 +25,7 @@ * Here. * * @author Kazuki Shimizu + * * @since 1.2.1 */ @SpringBootApplication diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/LICENSE_HEADER b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/LICENSE_HEADER new file mode 100644 index 00000000..a81590a5 --- /dev/null +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/LICENSE_HEADER @@ -0,0 +1,13 @@ + Copyright ${license.git.copyrightYears} 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. diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/format.xml b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/format.xml index c31af4e1..6d9e588e 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/format.xml +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/format.xml @@ -1,13 +1,13 @@ - + 4.0.0 org.mybatis.spring.boot mybatis-spring-boot-samples - 2.2.3-SNAPSHOT + 3.0.6-SNAPSHOT mybatis-spring-boot-sample-web jar diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/SampleWebApplication.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/SampleWebApplication.java index d8eba1cf..2d7c6834 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/SampleWebApplication.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/SampleWebApplication.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/controller/CityRestController.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/controller/CityRestController.java index e7574c4c..165ca27e 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/controller/CityRestController.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/controller/CityRestController.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -34,7 +34,7 @@ public CityRestController(CityMapper cityMapper) { } @GetMapping("{state}") - City getCity(@PathVariable String state) { + City getCity(@PathVariable("state") String state) { return cityMapper.findByState(state); } diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/domain/City.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/domain/City.java index 3adb2225..cf18fd08 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/domain/City.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/domain/City.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/mapper/CityMapper.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/mapper/CityMapper.java index 672f048a..8f6af1e5 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/mapper/CityMapper.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/java/sample/mybatis/web/mapper/CityMapper.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/resources/application.properties b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/resources/application.properties index 7bdf359e..b42aac19 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/resources/application.properties +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/resources/application.properties @@ -1,11 +1,11 @@ # -# Copyright 2015-2021 the original author or authors. +# Copyright 2015-2023 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 # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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, @@ -15,4 +15,4 @@ # logging.level.root=INFO -logging.level.sample.mybatis.web.mapper=TRACE \ No newline at end of file +logging.level.sample.mybatis.web.mapper=TRACE diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/resources/data.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/resources/data.sql index 4e42e5bc..ec1033b4 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/resources/data.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/resources/data.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2019 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/resources/schema.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/resources/schema.sql index c1ad2471..754fa57e 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/resources/schema.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/main/resources/schema.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2019 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/test/java/sample/mybatis/web/SampleMybatisApplicationTest.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/test/java/sample/mybatis/web/SampleMybatisApplicationTest.java index 0fe0df0e..4a0886e1 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/test/java/sample/mybatis/web/SampleMybatisApplicationTest.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/test/java/sample/mybatis/web/SampleMybatisApplicationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/test/java/sample/mybatis/web/SampleMybatisWithMockBeanApplicationTest.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/test/java/sample/mybatis/web/SampleMybatisWithMockBeanApplicationTest.java new file mode 100644 index 00000000..ebc11694 --- /dev/null +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/test/java/sample/mybatis/web/SampleMybatisWithMockBeanApplicationTest.java @@ -0,0 +1,62 @@ +/* + * Copyright 2015-2023 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 sample.mybatis.web; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Map; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.test.web.client.TestRestTemplate; + +import sample.mybatis.web.domain.City; +import sample.mybatis.web.mapper.CityMapper; + +/** + * @author Kazuki Shimizu + */ +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +class SampleMybatisWithMockBeanApplicationTest { + + @Autowired + private TestRestTemplate restTemplate; + + @MockBean + CityMapper cityMapper; + + @BeforeEach + void setup() { + City city = new City(); + city.setId(10L); + city.setCountry("US"); + city.setState("NV"); + city.setName("Las Vegas"); + Mockito.when(cityMapper.findByState("NV")).thenReturn(city); + } + + @Test + void test() { + @SuppressWarnings("unchecked") + Map body = this.restTemplate.getForObject("/cities/{state}", Map.class, "NV"); + assertThat(body).hasSize(4).containsEntry("id", 10).containsEntry("name", "Las Vegas").containsEntry("state", "NV") + .containsEntry("country", "US"); + } +} diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/test/java/sample/mybatis/web/mapper/CityMapperTest.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/test/java/sample/mybatis/web/mapper/CityMapperTest.java index 10440060..d89de56f 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/test/java/sample/mybatis/web/mapper/CityMapperTest.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/test/java/sample/mybatis/web/mapper/CityMapperTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -27,6 +27,7 @@ * Tests for {@link CityMapper}. * * @author wonwoo + * * @since 1.2.1 */ @MybatisTest diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/test/java/sample/mybatis/web/mapper/MapperTestApplication.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/test/java/sample/mybatis/web/mapper/MapperTestApplication.java index b64b38fe..d83fec6f 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/test/java/sample/mybatis/web/mapper/MapperTestApplication.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-web/src/test/java/sample/mybatis/web/mapper/MapperTestApplication.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -25,6 +25,7 @@ * Here. * * @author Kazuki Shimizu + * * @since 1.2.1 */ @SpringBootApplication diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/LICENSE_HEADER b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/LICENSE_HEADER new file mode 100644 index 00000000..a81590a5 --- /dev/null +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/LICENSE_HEADER @@ -0,0 +1,13 @@ + Copyright ${license.git.copyrightYears} 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. diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/format.xml b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/format.xml index c31af4e1..6d9e588e 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/format.xml +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/format.xml @@ -1,13 +1,13 @@ - + 4.0.0 org.mybatis.spring.boot mybatis-spring-boot-samples - 2.2.3-SNAPSHOT + 3.0.6-SNAPSHOT mybatis-spring-boot-sample-xml jar @@ -59,12 +59,12 @@ ${spring-boot.version} - - repackage - + + repackage + - + diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/SampleXmlApplication.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/SampleXmlApplication.java index c5a07745..d4802cce 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/SampleXmlApplication.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/SampleXmlApplication.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/dao/CityDao.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/dao/CityDao.java index 31abb94e..f8bb7504 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/dao/CityDao.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/dao/CityDao.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/domain/City.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/domain/City.java index c7de343e..82c3fe5e 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/domain/City.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/domain/City.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/domain/Hotel.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/domain/Hotel.java index 7c8d379a..466bc6c5 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/domain/Hotel.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/domain/Hotel.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2023 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -69,4 +69,4 @@ public String toString() { return getCity() + "," + getName() + "," + getAddress() + "," + getZip(); } -} \ No newline at end of file +} diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/mapper/CityMapper.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/mapper/CityMapper.java index 91d8e51a..45671021 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/mapper/CityMapper.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/mapper/CityMapper.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2023 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -17,7 +17,6 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; import sample.mybatis.xml.domain.City; @@ -27,7 +26,6 @@ @Mapper public interface CityMapper { - @Select("select id, name, state, country from city where state = #{state}") City findByState(@Param("state") String state); } diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/mapper/HotelMapper.java b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/mapper/HotelMapper.java index 5ab7807a..80a4e503 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/mapper/HotelMapper.java +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/java/sample/mybatis/xml/mapper/HotelMapper.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/resources/application.properties b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/resources/application.properties index d01a4ecd..64d60dde 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/resources/application.properties +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/resources/application.properties @@ -1,11 +1,11 @@ # -# Copyright 2015-2021 the original author or authors. +# Copyright 2015-2023 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 # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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, @@ -16,4 +16,4 @@ mybatis.config-location=classpath:mybatis-config.xml logging.level.root=WARN -logging.level.sample.mybatis.xml.mapper=TRACE \ No newline at end of file +logging.level.sample.mybatis.xml.mapper=TRACE diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/resources/data.sql b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/resources/data.sql index 6a4f41bf..511589ad 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/resources/data.sql +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/resources/data.sql @@ -1,11 +1,11 @@ -- --- Copyright 2015-2019 the original author or authors. +-- Copyright 2015-2022 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 -- --- http://www.apache.org/licenses/LICENSE-2.0 +-- 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, diff --git a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/resources/mybatis-config.xml b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/resources/mybatis-config.xml index f38d2460..1affd06c 100644 --- a/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/resources/mybatis-config.xml +++ b/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml/src/main/resources/mybatis-config.xml @@ -1,13 +1,13 @@ - + 4.0.0 org.mybatis.spring.boot mybatis-spring-boot - 2.2.3-SNAPSHOT + 3.0.6-SNAPSHOT mybatis-spring-boot-samples pom @@ -40,6 +40,7 @@ mybatis-spring-boot-sample-xml + org.mybatis.spring.sample true diff --git a/mybatis-spring-boot-samples/run_fatjars.sh b/mybatis-spring-boot-samples/run_fatjars.sh index 715e168b..5e0e4acf 100755 --- a/mybatis-spring-boot-samples/run_fatjars.sh +++ b/mybatis-spring-boot-samples/run_fatjars.sh @@ -1,12 +1,12 @@ #!/bin/bash # -# Copyright 2015-2020 the original author or authors. +# Copyright 2015-2022 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 # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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, diff --git a/mybatis-spring-boot-starter-test/LICENSE_HEADER b/mybatis-spring-boot-starter-test/LICENSE_HEADER new file mode 100644 index 00000000..a81590a5 --- /dev/null +++ b/mybatis-spring-boot-starter-test/LICENSE_HEADER @@ -0,0 +1,13 @@ + Copyright ${license.git.copyrightYears} 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. diff --git a/mybatis-spring-boot-starter-test/format.xml b/mybatis-spring-boot-starter-test/format.xml index c31af4e1..6d9e588e 100644 --- a/mybatis-spring-boot-starter-test/format.xml +++ b/mybatis-spring-boot-starter-test/format.xml @@ -1,13 +1,13 @@ - + 4.0.0 - mybatis-spring-boot org.mybatis.spring.boot - 2.2.3-SNAPSHOT + mybatis-spring-boot + 3.0.6-SNAPSHOT mybatis-spring-boot-starter-test mybatis-spring-boot-starter-test org.mybatis.spring.boot.starter.test + false + @@ -38,4 +40,4 @@ mybatis-spring-boot-test-autoconfigure - \ No newline at end of file + diff --git a/mybatis-spring-boot-starter-test/src/main/java/org/mybatis/spring/boot/starter/test/package-info.java b/mybatis-spring-boot-starter-test/src/main/java/org/mybatis/spring/boot/starter/test/package-info.java new file mode 100644 index 00000000..a766bd44 --- /dev/null +++ b/mybatis-spring-boot-starter-test/src/main/java/org/mybatis/spring/boot/starter/test/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2015-2024 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. + */ +/** + * MyBatis-Spring-Boot-Starter for testing. + */ +// This file added for generating javadoc jar and source jar file. +package org.mybatis.spring.boot.starter.test; \ No newline at end of file diff --git a/mybatis-spring-boot-starter/LICENSE_HEADER b/mybatis-spring-boot-starter/LICENSE_HEADER new file mode 100644 index 00000000..a81590a5 --- /dev/null +++ b/mybatis-spring-boot-starter/LICENSE_HEADER @@ -0,0 +1,13 @@ + Copyright ${license.git.copyrightYears} 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. diff --git a/mybatis-spring-boot-starter/format.xml b/mybatis-spring-boot-starter/format.xml index c31af4e1..6d9e588e 100644 --- a/mybatis-spring-boot-starter/format.xml +++ b/mybatis-spring-boot-starter/format.xml @@ -1,13 +1,13 @@ - + 4.0.0 org.mybatis.spring.boot mybatis-spring-boot - 2.2.3-SNAPSHOT + 3.0.6-SNAPSHOT mybatis-spring-boot-starter mybatis-spring-boot-starter org.mybatis.spring.boot.starter + false + @@ -50,4 +52,20 @@ mybatis-spring + + + + + biz.aQute.bnd + bnd-maven-plugin + + + + + + diff --git a/mybatis-spring-boot-starter/src/main/java/org/mybatis/spring/boot/starter/package-info.java b/mybatis-spring-boot-starter/src/main/java/org/mybatis/spring/boot/starter/package-info.java new file mode 100644 index 00000000..3f7a1846 --- /dev/null +++ b/mybatis-spring-boot-starter/src/main/java/org/mybatis/spring/boot/starter/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2015-2024 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. + */ +/** + * MyBatis-Spring-Boot-Starter. + */ +// This file added for generating javadoc jar and source jar file. +package org.mybatis.spring.boot.starter; \ No newline at end of file diff --git a/mybatis-spring-boot-test-autoconfigure/LICENSE_HEADER b/mybatis-spring-boot-test-autoconfigure/LICENSE_HEADER new file mode 100644 index 00000000..a81590a5 --- /dev/null +++ b/mybatis-spring-boot-test-autoconfigure/LICENSE_HEADER @@ -0,0 +1,13 @@ + Copyright ${license.git.copyrightYears} 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. diff --git a/mybatis-spring-boot-test-autoconfigure/format.xml b/mybatis-spring-boot-test-autoconfigure/format.xml index c31af4e1..6d9e588e 100644 --- a/mybatis-spring-boot-test-autoconfigure/format.xml +++ b/mybatis-spring-boot-test-autoconfigure/format.xml @@ -1,13 +1,13 @@ - + 4.0.0 - mybatis-spring-boot org.mybatis.spring.boot - 2.2.3-SNAPSHOT + mybatis-spring-boot + 3.0.6-SNAPSHOT mybatis-spring-boot-test-autoconfigure mybatis-spring-boot-test-autoconfigure @@ -44,12 +44,6 @@ org.springframework spring-test - - - commons-logging - commons-logging - - org.springframework @@ -76,4 +70,4 @@ test - \ No newline at end of file + diff --git a/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/AutoConfigureMybatis.java b/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/AutoConfigureMybatis.java index 977cdeff..5233bc78 100644 --- a/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/AutoConfigureMybatis.java +++ b/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/AutoConfigureMybatis.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -29,6 +29,7 @@ * using {@link MybatisTest @MybatisTest} rather than using this annotation directly. * * @author wonwoo + * * @since 1.2.1 */ @Target(ElementType.TYPE) diff --git a/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTest.java b/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTest.java index 7a05a8c3..d5cdfc36 100644 --- a/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTest.java +++ b/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -55,7 +55,9 @@ * rather than this annotation. * * @author wonwoo + * * @see AutoConfigureMybatis + * * @since 1.2.1 */ @Target(ElementType.TYPE) @@ -78,6 +80,7 @@ * runs. * * @return the properties to add + * * @since 2.1.0 */ String[] properties() default {}; @@ -87,6 +90,7 @@ * default no beans are included. * * @return if default filters should be used + * * @see #includeFilters() * @see #excludeFilters() */ diff --git a/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTestContextBootstrapper.java b/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTestContextBootstrapper.java index 1b1dd364..fb048cb3 100644 --- a/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTestContextBootstrapper.java +++ b/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTestContextBootstrapper.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -23,6 +23,7 @@ * {@link TestContextBootstrapper} for {@link MybatisTest @MybatisTest} support. * * @author Kazuki Shimizu + * * @since 2.1.0 */ class MybatisTestContextBootstrapper extends SpringBootTestContextBootstrapper { diff --git a/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTypeExcludeFilter.java b/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTypeExcludeFilter.java index 50d99ac4..5a7ee9bc 100644 --- a/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTypeExcludeFilter.java +++ b/mybatis-spring-boot-test-autoconfigure/src/main/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTypeExcludeFilter.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -27,6 +27,7 @@ * {@link TypeExcludeFilter} for {@link MybatisTest @MybatisTest}. * * @author wonwoo + * * @since 1.2.1 */ class MybatisTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter { diff --git a/mybatis-spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories b/mybatis-spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories old mode 100755 new mode 100644 index 27c5f018..617ddbff --- a/mybatis-spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories +++ b/mybatis-spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories @@ -1,3 +1,19 @@ +# +# Copyright 2015-2025 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. +# + # AutoConfigureMybatis auto-configuration imports org.mybatis.spring.boot.test.autoconfigure.AutoConfigureMybatis=\ org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration,\ diff --git a/mybatis-spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.mybatis.spring.boot.test.autoconfigure.AutoConfigureMybatis.imports b/mybatis-spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.mybatis.spring.boot.test.autoconfigure.AutoConfigureMybatis.imports new file mode 100644 index 00000000..ee48bc0c --- /dev/null +++ b/mybatis-spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.mybatis.spring.boot.test.autoconfigure.AutoConfigureMybatis.imports @@ -0,0 +1,10 @@ +# AutoConfigureMybatis auto-configuration imports +org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration +org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration +org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration +org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration +org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration +org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration +org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration +org.mybatis.spring.boot.autoconfigure.MybatisLanguageDriverAutoConfiguration +org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration diff --git a/mybatis-spring-boot-test-autoconfigure/src/site/markdown/index.md b/mybatis-spring-boot-test-autoconfigure/src/site/markdown/index.md index f163f4be..4c040dfd 100644 --- a/mybatis-spring-boot-test-autoconfigure/src/site/markdown/index.md +++ b/mybatis-spring-boot-test-autoconfigure/src/site/markdown/index.md @@ -1,5 +1,14 @@ # Introduction +## Translations + +Users can read about MyBatis-Spring-Boot-Starter-Test in the following translations: + +

+ ## What is MyBatis-Spring-Boot-Starter-Test? The MyBatis-Spring-Boot-Starter-Test help creating a test cases for MyBatis component using the [MyBatis-Spring-Boot-Starter](http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/). @@ -13,13 +22,15 @@ By using this module you will can be: The MyBatis-Spring-Boot-Starter-Test requires following versions: -| MyBatis-Spring-Boot-Starter-Test | Spring Boot | Java | -| --- | --- | --- | -| **2.2** | 2.5 or higher | 8 or higher | -| **2.1** | 2.1 - 2.4 | 8 or higher | -| **~~2.0 (EOL)~~** | ~~2.0 or 2.1~~ | ~~8 or higher~~ | -| **~~1.3 (EOL)~~** | ~~1.5~~ | ~~6 or higher~~ | -| **~~1.2 (EOL)~~** | ~~1.4~~ | ~~6 or higher~~ | +| MyBatis-Spring-Boot-Starter-Test | Spring Boot | Java | +|----------------------------------|----------------|-----------------| +| **3.0** | 3.0 - 3.5 | 17 or higher | +| **2.3** | 2.7 | 8 or higher | +| **~~2.2 (EOL)~~** | ~~2.5 - 2.7~~ | ~~8 or higher~~ | +| **~~2.1 (EOL)~~** | ~~2.1 - 2.4~~ | ~~8 or higher~~ | +| **~~2.0 (EOL)~~** | ~~2.0 or 2.1~~ | ~~8 or higher~~ | +| **~~1.3 (EOL)~~** | ~~1.5~~ | ~~6 or higher~~ | +| **~~1.2 (EOL)~~** | ~~1.4~~ | ~~6 or higher~~ | ## Installation @@ -42,7 +53,7 @@ If using gradle add this to your `build.gradle`: ```groovy dependencies { - testCompile("org.mybatis.spring.boot:mybatis-spring-boot-starter-test:${project.version}") + testImplementation("org.mybatis.spring.boot:mybatis-spring-boot-starter-test:${project.version}") } ``` diff --git a/mybatis-spring-boot-test-autoconfigure/src/site/resources/css/site.css b/mybatis-spring-boot-test-autoconfigure/src/site/resources/css/site.css new file mode 100644 index 00000000..14a9eebc --- /dev/null +++ b/mybatis-spring-boot-test-autoconfigure/src/site/resources/css/site.css @@ -0,0 +1,29 @@ +/** + * Copyright 2015-2023 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. + */ +/* + * when new flags are needed, take them from + * + * https://www.printableworldflags.com/flag-icon + * + * that are free for any kind of usage + */ + +ul.i18n {list-style-type:none;} +li.en {background: url('../images/en.png') left no-repeat;padding-left: 32px; margin: 10px} +li.es {background: url('../images/es.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ja {background: url('../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px} +li.zh {background: url('../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ko {background: url('../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px} diff --git a/mybatis-spring-boot-test-autoconfigure/src/site/resources/es/css/site.css b/mybatis-spring-boot-test-autoconfigure/src/site/resources/es/css/site.css new file mode 100644 index 00000000..804cd2bb --- /dev/null +++ b/mybatis-spring-boot-test-autoconfigure/src/site/resources/es/css/site.css @@ -0,0 +1,29 @@ +/** + * Copyright 2015-2023 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. + */ +/* + * when new flags are needed, take them from + * + * https://www.printableworldflags.com/flag-icon + * + * that are free for any kind of usage + */ + +ul.i18n {list-style-type:none;} +li.en {background: url('../../images/en.png') left no-repeat;padding-left: 32px; margin: 10px} +li.es {background: url('../../images/es.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ja {background: url('../../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px} +li.zh {background: url('../../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ko {background: url('../../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px} diff --git a/mybatis-spring-boot-test-autoconfigure/src/site/resources/images/en.png b/mybatis-spring-boot-test-autoconfigure/src/site/resources/images/en.png new file mode 100644 index 00000000..82cf5f1c Binary files /dev/null and b/mybatis-spring-boot-test-autoconfigure/src/site/resources/images/en.png differ diff --git a/mybatis-spring-boot-test-autoconfigure/src/site/resources/images/es.png b/mybatis-spring-boot-test-autoconfigure/src/site/resources/images/es.png new file mode 100644 index 00000000..a4177e9f Binary files /dev/null and b/mybatis-spring-boot-test-autoconfigure/src/site/resources/images/es.png differ diff --git a/mybatis-spring-boot-test-autoconfigure/src/site/resources/images/ja.png b/mybatis-spring-boot-test-autoconfigure/src/site/resources/images/ja.png new file mode 100644 index 00000000..67020dfc Binary files /dev/null and b/mybatis-spring-boot-test-autoconfigure/src/site/resources/images/ja.png differ diff --git a/mybatis-spring-boot-test-autoconfigure/src/site/resources/images/ko.png b/mybatis-spring-boot-test-autoconfigure/src/site/resources/images/ko.png new file mode 100644 index 00000000..0e3d7062 Binary files /dev/null and b/mybatis-spring-boot-test-autoconfigure/src/site/resources/images/ko.png differ diff --git a/mybatis-spring-boot-test-autoconfigure/src/site/resources/images/zh.png b/mybatis-spring-boot-test-autoconfigure/src/site/resources/images/zh.png new file mode 100644 index 00000000..86ac698b Binary files /dev/null and b/mybatis-spring-boot-test-autoconfigure/src/site/resources/images/zh.png differ diff --git a/mybatis-spring-boot-test-autoconfigure/src/site/resources/ja/css/site.css b/mybatis-spring-boot-test-autoconfigure/src/site/resources/ja/css/site.css new file mode 100644 index 00000000..804cd2bb --- /dev/null +++ b/mybatis-spring-boot-test-autoconfigure/src/site/resources/ja/css/site.css @@ -0,0 +1,29 @@ +/** + * Copyright 2015-2023 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. + */ +/* + * when new flags are needed, take them from + * + * https://www.printableworldflags.com/flag-icon + * + * that are free for any kind of usage + */ + +ul.i18n {list-style-type:none;} +li.en {background: url('../../images/en.png') left no-repeat;padding-left: 32px; margin: 10px} +li.es {background: url('../../images/es.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ja {background: url('../../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px} +li.zh {background: url('../../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ko {background: url('../../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px} diff --git a/mybatis-spring-boot-test-autoconfigure/src/site/resources/ko/css/site.css b/mybatis-spring-boot-test-autoconfigure/src/site/resources/ko/css/site.css new file mode 100644 index 00000000..804cd2bb --- /dev/null +++ b/mybatis-spring-boot-test-autoconfigure/src/site/resources/ko/css/site.css @@ -0,0 +1,29 @@ +/** + * Copyright 2015-2023 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. + */ +/* + * when new flags are needed, take them from + * + * https://www.printableworldflags.com/flag-icon + * + * that are free for any kind of usage + */ + +ul.i18n {list-style-type:none;} +li.en {background: url('../../images/en.png') left no-repeat;padding-left: 32px; margin: 10px} +li.es {background: url('../../images/es.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ja {background: url('../../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px} +li.zh {background: url('../../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ko {background: url('../../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px} diff --git a/mybatis-spring-boot-test-autoconfigure/src/site/resources/zh_CN/css/site.css b/mybatis-spring-boot-test-autoconfigure/src/site/resources/zh_CN/css/site.css new file mode 100644 index 00000000..804cd2bb --- /dev/null +++ b/mybatis-spring-boot-test-autoconfigure/src/site/resources/zh_CN/css/site.css @@ -0,0 +1,29 @@ +/** + * Copyright 2015-2023 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. + */ +/* + * when new flags are needed, take them from + * + * https://www.printableworldflags.com/flag-icon + * + * that are free for any kind of usage + */ + +ul.i18n {list-style-type:none;} +li.en {background: url('../../images/en.png') left no-repeat;padding-left: 32px; margin: 10px} +li.es {background: url('../../images/es.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ja {background: url('../../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px} +li.zh {background: url('../../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px} +li.ko {background: url('../../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px} diff --git a/mybatis-spring-boot-test-autoconfigure/src/site/site.xml b/mybatis-spring-boot-test-autoconfigure/src/site/site.xml index 7d2d4879..de229266 100644 --- a/mybatis-spring-boot-test-autoconfigure/src/site/site.xml +++ b/mybatis-spring-boot-test-autoconfigure/src/site/site.xml @@ -1,13 +1,13 @@ - + @@ -26,4 +26,4 @@ - + diff --git a/mybatis-spring-boot-test-autoconfigure/src/site/site_zh.xml b/mybatis-spring-boot-test-autoconfigure/src/site/site_zh.xml new file mode 100644 index 00000000..aa69211b --- /dev/null +++ b/mybatis-spring-boot-test-autoconfigure/src/site/site_zh.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + diff --git a/mybatis-spring-boot-test-autoconfigure/src/site/zh_CN/markdown/index.md b/mybatis-spring-boot-test-autoconfigure/src/site/zh_CN/markdown/index.md new file mode 100644 index 00000000..4567fcd4 --- /dev/null +++ b/mybatis-spring-boot-test-autoconfigure/src/site/zh_CN/markdown/index.md @@ -0,0 +1,319 @@ +# 简介 + +## 文档的翻译版本 + +可以阅读 MyBatis-Spring-Boot-Starter-Test 文档的以下翻译版本: + + + +## 什么是 MyBatis-Spring-Boot-Starter-Test? + +MyBatis-Spring-Boot-Starter-Test 为 [MyBatis-Spring-Boot-Starter](http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/) 中的 MyBatis 组件提供测试用例。 + +使用它你将可以做到: + +* 可以使用 `@MybatisTest` 单独为 MyBatis 组件进行测试 +* 在测试 MyBatis 组件时,可以导入依赖 + +TheMyBatis-Spring-Boot-Starter-Test 要求以下版本: + +| MyBatis-Spring-Boot-Starter-Test | Spring Boot | Java | +|----------------------------------|---------------|-----------| +| **3.0** | 3.0 - 3.4 | 17 或更高 | +| **2.3** | 2.7 | 8 或更高 | +| **~~2.2 (EOL)~~** | ~~2.5 - 2.7~~ | ~~8 或更高~~ | +| **~~2.1 (EOL)~~** | ~~2.1 - 2.4~~ | ~~8 或更高~~ | +| **~~2.0 (EOL)~~** | ~~2.0 或 2.1~~ | ~~8 或更高~~ | +| **~~1.3 (EOL)~~** | ~~1.5~~ | ~~6 或更高~~ | +| **~~1.2 (EOL)~~** | ~~1.4~~ | ~~6 或更高~~ | + +## 安装 + +### Maven + +如果你使用 Maven,只需要将下面的依赖放入你的 `pom.xml`: + +```xml + + org.mybatis.spring.boot + mybatis-spring-boot-starter-test + ${project.version} + test + +``` + +### Gradle + +如果使用 Gradle,在 `build.gradle` 中加入以下内容: + +```groovy +dependencies { + testImplementation("org.mybatis.spring.boot:mybatis-spring-boot-starter-test:${project.version}") +} +``` + +## 使用 @MybatisTest + +当你想对 MyBatis 组件进行测试时,可以使用 `@MybatisTest` (Mapper 接口与 `SqlSession`)。 +默认情况下, 它将会配置 MyBatis(MyBatis-Spring)组件(`SqlSessionFactory` 与 `SqlSessionTemplate`),配置 MyBatis mapper 接口和内存中的内嵌的数据库。 +MyBatis 测试默认情况下基于事务,且在测试的结尾进行回滚。 +更多相关的信息可参见 [Spring 参考文档](https://docs.spring.io/spring/docs/current/spring-framework-reference/testing.html#testcontext-tx-enabling-transactions) 。 +再者,普遍情况下 `@Component` beans 将不会被载入 `ApplicationContext` 。 + +### 对 Mapper 接口进行测试 + +如果你想对下面的 Mapper 接口进行测试,你只需要将 `@MybatisTest` 添加在测试类上。 + +Mapper 接口: + +```java +package sample.mybatis.mapper; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import sample.mybatis.domain.City; + +@Mapper +public interface CityMapper { + + @Select("SELECT * FROM CITY WHERE state = #{state}") + City findByState(@Param("state") String state); + +} +``` + +测试类: + +```java +package sample.mybatis.mapper; + +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.mybatis.spring.boot.test.autoconfigure.MybatisTest; +import sample.mybatis.domain.City; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@MybatisTest +public class CityMapperTest { + + @Autowired + private CityMapper cityMapper; + + @Test + public void findByStateTest() { + City city = cityMapper.findByState("CA"); + assertThat(city.getName()).isEqualTo("San Francisco"); + assertThat(city.getState()).isEqualTo("CA"); + assertThat(city.getCountry()).isEqualTo("US"); + } + +} +``` + +### DAO 模式下的测试 + +如果你为下面的 DAO 类创建测试,你只需要将 `@MybatisTest` 和 `@Import` 添加在你的测试类上。 + +DAO 类: + +```java +package sample.mybatis.dao; + +import org.apache.ibatis.session.SqlSession; +import sample.mybatis.domain.City; + +import org.springframework.stereotype.Component; + +@Component +public class CityDao { + + private final SqlSession sqlSession; + + public CityDao(SqlSession sqlSession) { + this.sqlSession = sqlSession; + } + + public City selectCityById(long id) { + return this.sqlSession.selectOne("selectCityById", id); + } + +} +``` + +测试类: + +```java +package sample.mybatis.dao; + +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.mybatis.spring.boot.test.autoconfigure.MybatisTest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.junit4.SpringRunner; +import sample.mybatis.domain.City; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@MybatisTest +@Import(CityDao.class) +public class CityDaoTest { + + @Autowired + private CityDao cityDao; + + @Test + public void selectCityByIdTest() { + City city = cityDao.selectCityById(1); + assertThat(city.getName()).isEqualTo("San Francisco"); + assertThat(city.getState()).isEqualTo("CA"); + assertThat(city.getCountry()).isEqualTo("US"); + } + +} +``` + +## 使用真实的数据库 + +内嵌的数据库通常在测试上表现良好,因为们很快,且不需要安装一些开发工具。 +然而如果你希望使用真实的数据库,你可以像下面这样使用 `@AutoConfigureTestDatabase` : + +```java +package sample.mybatis.mapper; +// ... +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; + +@RunWith(SpringRunner.class) +@MybatisTest +@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) +public class CityMapperTest { + // ... +} +``` + +## 避免探测到真实的 @SpringBootApplication + + `@MybatisTest` 在默认情况下将会探测到带有 `@SpringBootApplication` 的类。 +因此,由于 bean 定义的一些方法,可能会发生一些意想不到的错误,或者一些不必要的组件被装入 `ApplicationContext` 。 +为了避免这种情况,我们可以在与测试类相同的包中创建带有 `@SpringBootApplication` 的类。 + +```java +package sample.mybatis.mapper; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +class MapperTestApplication { + +} +``` + +## 与其他 @***Test 一起使用 + +如果 `@MybatisTest` 与其他的 `@***Test` 一起使用(例如: `@WebMvcTest`), +请考虑使用 `@AutoConfigureMybatis` ,因为不能在同一测试中指定两个或多个`@***Test` 注解。 + +测试的目标类: + +```java +@RestController +public class PingController { + PingMapper mapper; + + PingController(PingMapper mapper) { + this.mapper = mapper; + } + + @GetMapping("ping") + String ping() { + return mapper.ping(); + } +} +``` + +```java +@Mapper +public interface PingMapper { +@Select("SELECT 'OK'") + String ping(); +} +``` + +测试类: + +```java +@RunWith(SpringRunner.class) +@WebMvcTest +@AutoConfigureMybatis // 替代 @MybatisTest +public class PingTests { + + @Autowired + private MockMvc mvc; + + @Test + public void ping() throws Exception { + this.mvc.perform(get("/ping")) + .andExpect(status().isOk()) + .andExpect(content().string("OK")); + } + +} +``` + +## 在 JUnit 5 上使用 @MybatisTest + +`@MybatisTest` 可以在 JUnit 5 上使用: + +```java +@ExtendWith(SpringExtension.class) +@MybatisTest +public class CityMapperTest { + // ... +} +``` + +自 2.0.1 起, `@ExtendWith(SpringExtension.class)` 可以像下面这样被忽略: + +```java +@MybatisTest +public class CityMapperTest { + // ... +} +``` + +## 附录 + +### 导入的自动配置 + + `@MybatisTest` 将会导入以下自动配置的类: + +* `org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration` +* `org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration` +* `org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration` +* `org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration` +* `org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration` +* `org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration` +* `org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration` +* `org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration` +* `org.mybatis.spring.boot.autoconfigure.MybatisLanguageDriverAutoConfiguration` +* `org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration` + +### 可运行的样例 + +项目(为每个类型)提供了两个样例供使用: + +| 分类 | 样例 | 描述 | +|:------ |:----------------------------------------------------------------------------------------------------------------------------------- |:--------------------------------------------------------------------- | +| 核心 | [样例1](https://github.com/mybatis/spring-boot-starter/tree/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-annotation) | 展示了最简单的场景,只有一个 mapper 和一个注入 mapper 的组件。这就是我们在“快速入门”部分看到的例子。 | +| | [样例2](https://github.com/mybatis/spring-boot-starter/tree/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-xml) | 展示了如何在 XML 文件中使用一个带有语句的 Mapper,并且也有使用 `SqlSessionTemplate` 的 DAO 的示例。 | +| JVM 语言 | [样例3](https://github.com/mybatis/spring-boot-starter/tree/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-kotlin) | 展示了如何和 kotlin 一同使用。 | +| | [样例4](https://github.com/mybatis/spring-boot-starter/tree/master/mybatis-spring-boot-samples/mybatis-spring-boot-sample-groovy) | 展示了如何和 groovy 一同使用。 | diff --git a/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleComponent.java b/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleComponent.java index cfd438ff..a1cc0542 100755 --- a/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleComponent.java +++ b/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleComponent.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -21,6 +21,7 @@ * Example component that annotated {@link Component @Component} used with {@link MybatisTest} tests. * * @author wonwoo + * * @since 1.2.1 */ @Component diff --git a/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleMybatisApplication.java b/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleMybatisApplication.java index 94b38db7..62bbdb1e 100644 --- a/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleMybatisApplication.java +++ b/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleMybatisApplication.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -22,6 +22,7 @@ * Example {@link SpringBootApplication} used with {@link MybatisTest} tests. * * @author wonwoo + * * @since 1.2.1 */ @SpringBootApplication diff --git a/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleService.java b/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleService.java index 86e88a02..d1d4a759 100755 --- a/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleService.java +++ b/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/ExampleService.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -21,6 +21,7 @@ * Example component that annotated {@link Service @Service} used with {@link MybatisTest} tests. * * @author Kazuki Shimizu + * * @since 1.2.1 */ @Service diff --git a/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTestCustomFilterIntegrationTest.java b/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTestCustomFilterIntegrationTest.java index 58a6fd13..78e7cdad 100644 --- a/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTestCustomFilterIntegrationTest.java +++ b/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTestCustomFilterIntegrationTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -28,6 +28,7 @@ * Integration test with custom filter for {@link MybatisTest}. * * @author Kazuki Shimizu + * * @since 1.2.1 */ @MybatisTest(includeFilters = @ComponentScan.Filter(Component.class), excludeFilters = @ComponentScan.Filter(Service.class)) diff --git a/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTestIntegrationTest.java b/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTestIntegrationTest.java index 6eefedf0..7c45dc19 100755 --- a/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTestIntegrationTest.java +++ b/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/MybatisTestIntegrationTest.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -37,6 +37,7 @@ * Integration tests for {@link MybatisTest}. * * @author wonwoo + * * @since 1.2.1 */ @MybatisTest(properties = { "mybatis.type-aliases-package=org.mybatis.spring.boot.test.autoconfigure", diff --git a/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/Sample.java b/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/Sample.java index 2a28e488..c8626bce 100755 --- a/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/Sample.java +++ b/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/Sample.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -19,6 +19,7 @@ * Example entity used with {@link MybatisTest} tests. * * @author wonwoo + * * @since 1.2.1 */ public class Sample { diff --git a/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/SampleMapper.java b/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/SampleMapper.java index 5ce0ce99..59c78ba0 100755 --- a/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/SampleMapper.java +++ b/mybatis-spring-boot-test-autoconfigure/src/test/java/org/mybatis/spring/boot/test/autoconfigure/SampleMapper.java @@ -1,11 +1,11 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2022 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -21,6 +21,7 @@ * Example mapper used with {@link MybatisTest} tests. * * @author wonwoo + * * @since 1.2.1 */ @Mapper diff --git a/mybatis-spring-boot-test-autoconfigure/src/test/resources/org/mybatis/spring/boot/test/autoconfigure/SampleMapper.xml b/mybatis-spring-boot-test-autoconfigure/src/test/resources/org/mybatis/spring/boot/test/autoconfigure/SampleMapper.xml index 976c8016..caba0375 100755 --- a/mybatis-spring-boot-test-autoconfigure/src/test/resources/org/mybatis/spring/boot/test/autoconfigure/SampleMapper.xml +++ b/mybatis-spring-boot-test-autoconfigure/src/test/resources/org/mybatis/spring/boot/test/autoconfigure/SampleMapper.xml @@ -1,13 +1,13 @@ - + + 4.0.0 org.mybatis mybatis-parent - 34 + 51 org.mybatis.spring.boot mybatis-spring-boot - 2.2.3-SNAPSHOT + 3.0.6-SNAPSHOT pom mybatis-spring-boot Spring Boot Support for MyBatis - http://www.mybatis.org/spring-boot-starter/ + https://www.mybatis.org/spring-boot-starter/ 2015 @@ -45,61 +46,49 @@ - scm:git:git@github.com:mybatis/spring-boot-starter.git - scm:git:git@github.com:mybatis/spring-boot-starter.git - https://github.com/mybatis/spring-boot-starter/tree/master - HEAD + scm:git:ssh://git@github.com/mybatis/spring-boot-starter.git + scm:git:ssh://git@github.com/mybatis/spring-boot-starter.git + mybatis-spring-boot-3.0.4 + https://github.com/mybatis/spring-boot-starter/ GitHub Issue Management https://github.com/mybatis/spring-boot-starter/issues - Travis CI - https://travis-ci.org/mybatis/spring-boot-starter + GitHub Actions + https://github.com/mybatis/spring-boot-starter/actions - gh-pages + gh-pages-scm Mybatis GitHub Pages - git:ssh://git@github.com/mybatis/spring-boot-starter.git?gh-pages# + scm:git:ssh://git@github.com/mybatis/spring-boot-starter.git - 3.5.9 - 2.0.7 - 1.2.3 - 2.1.1 - 1.0.3 - 2.6.7 - + + 17 + 17 - - - - ${project.basedir}/src/main/resources - true - - - ${project.basedir}/src/site - ${project.build.directory}/site-src - true - - - - - - org.apache.maven.plugins - maven-site-plugin - - - ${project.build.directory}/site-src - - - - - + 3.5.19 + 3.0.5 + 1.3.0 + 2.3.0 + 1.1.0 + 3.5.6 + + --add-opens java.base/java.lang=ALL-UNNAMED -Dfile.encoding=UTF-8 + + + 1749572979 + + org.mybatis.spring.boot + + + + @@ -170,39 +159,105 @@ https://oss.sonatype.org/content/repositories/snapshots - spring-milestone - Spring Milestone - https://repo.spring.io/milestone false + spring-milestone + Spring Milestone + https://repo.spring.io/milestone - spring-snapshot - Spring Snapshot - https://repo.spring.io/snapshot true + spring-snapshot + Spring Snapshot + https://repo.spring.io/snapshot - spring-milestone - Spring Milestone - https://repo.spring.io/milestone false + spring-milestone + Spring Milestone + https://repo.spring.io/milestone - spring-snapshot - Spring Snapshot - https://repo.spring.io/snapshot true + spring-snapshot + Spring Snapshot + https://repo.spring.io/snapshot + + + + + org.apache.maven.plugins + maven-resources-plugin + + + + filter-site + + copy-resources + + pre-site + + ${project.build.directory}/site-src + + + src/site + true + + + + + + + + org.apache.maven.plugins + maven-site-plugin + + default,zh_CN + ${project.build.directory}/site-src + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + + + + org.apache.tomcat:tomcat-coyote-ffm + org.apache.tomcat.embed:tomcat-embed-core + + + + + + + + + diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000..5db72dd6 --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended" + ] +} diff --git a/scripts/get_latest_version.sh b/scripts/get_latest_version.sh deleted file mode 100755 index 42a21df0..00000000 --- a/scripts/get_latest_version.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# -# Copyright 2015-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 -# -# http://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. -# - - -targetMinorVersion=$1 -majorVersion=${targetMinorVersion%.*} -minorVersion=${targetMinorVersion#*.} -while read -r line; do - maintenanceVersion=${line#${targetMinorVersion}.} && maintenanceVersion=${maintenanceVersion%%.*} - maintenanceVersions="${maintenanceVersions}${maintenanceVersion}"$'\n' -done<${majorVersion}\.${minorVersion}\.[0-9]*") -END -echo "${targetMinorVersion}.$(echo "${maintenanceVersions}" | sort -n | tail -n 1).RELEASE"