Skip to content

Commit 62cce8e

Browse files
committed
Add first content
Fixes gh-1
1 parent b4c010c commit 62cce8e

File tree

193 files changed

+10378
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+10378
-1
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: maven
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
labels:
8+
- dependencies

.github/workflows/ci.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Java CI
2+
on:
3+
push:
4+
pull_request:
5+
jobs:
6+
build:
7+
name: Verify on ${{ matrix.os }} (Java ${{ matrix.java }})
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os:
12+
- 'ubuntu-latest'
13+
- 'windows-latest'
14+
- 'macos-latest'
15+
java:
16+
- 11
17+
- 17
18+
fail-fast: false
19+
max-parallel: 6
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up JDK
23+
uses: actions/setup-java@v2
24+
with:
25+
java-version: ${{ matrix.java }}
26+
distribution: 'zulu'
27+
- name: Cache local Maven repository
28+
uses: actions/cache@v2
29+
with:
30+
path: ~/.m2/repository
31+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
32+
restore-keys: |
33+
${{ runner.os }}-maven-
34+
- name: Show a Java version
35+
run: java -version
36+
- name: Verify a mybatis-spring-native-core
37+
run: ./mvnw -U -pl .,core,extensions clean verify -D"license.skip=true"

.github/workflows/samples.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Samples
2+
on:
3+
push:
4+
pull_request:
5+
jobs:
6+
build:
7+
name: Run ${{ matrix.sample }} on ${{ matrix.os }} (GraalVM ${{ matrix.java }})
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os:
12+
- 'ubuntu-latest'
13+
- 'windows-latest'
14+
java:
15+
- 17
16+
sample:
17+
- 'simple'
18+
- 'xml'
19+
- 'sqlprovider'
20+
- 'scan'
21+
- 'dao'
22+
- 'thymeleaf'
23+
- 'thymeleaf-sqlgenerator'
24+
- 'velocity'
25+
- 'freemarker'
26+
- 'cache'
27+
- 'configuration'
28+
- 'dynamic-sql'
29+
fail-fast: false
30+
max-parallel: 10
31+
steps:
32+
- uses: actions/checkout@v2
33+
- name: Set up GraalVM
34+
uses: graalvm/setup-graalvm@v1
35+
with:
36+
version: 'latest'
37+
java-version: ${{ matrix.java }}
38+
components: 'native-image'
39+
github-token: ${{ secrets.GITHUB_TOKEN }}
40+
- name: Cache local Maven repository
41+
uses: actions/cache@v2
42+
with:
43+
path: ~/.m2/repository
44+
key: ${{ runner.os }}-maven-samples-${{ hashFiles('**/pom.xml') }}
45+
restore-keys: |
46+
${{ runner.os }}-maven-samples-
47+
- name: Print environments
48+
run: |
49+
echo "GRAALVM_HOME: $GRAALVM_HOME"
50+
echo "JAVA_HOME: $JAVA_HOME"
51+
java --version
52+
native-image --version
53+
- name: Build native image
54+
run: ./mvnw -pl core,extensions,samples/${{ matrix.sample }} -U -D"maven.test.skip" -Pnative -D"license.skip=true" clean package
55+
- name: Run with native image
56+
run: ./samples/${{ matrix.sample }}/target/mybatis-spring-native-sample-${{ matrix.sample }}
57+
- name: Run with executable jar on AOT mode
58+
run: java -DspringAot=true -jar ./samples/${{ matrix.sample }}/target/mybatis-spring-native-sample-${{ matrix.sample }}-exec.jar
59+
- name: Run with executable jar
60+
run: java -jar ./samples/${{ matrix.sample }}/target/mybatis-spring-native-sample-${{ matrix.sample }}-exec.jar
61+
- name: Verify running with native image for ubuntu
62+
if: ${{ matrix.os == 'ubuntu-latest' }}
63+
run: |
64+
./samples/${{ matrix.sample }}/target/mybatis-spring-native-sample-${{ matrix.sample }} --logging.pattern.console="[%level] %m%n" --spring.main.banner-mode=off --logging.level.org.mybatis.spring.nativex.sample=off | tee actual-console.log
65+
diff actual-console.log ./samples/${{ matrix.sample }}/src/test/resources/expected-console.log

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
HELP.md
2+
target/
3+
.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/

.mvn/wrapper/maven-wrapper.properties

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Please see [the MyBatis core module Guideline](https://github.com/mybatis/mybatis-3/blob/master/CONTRIBUTING.md).

README.md

Lines changed: 186 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,186 @@
1-
# spring-native
1+
# MyBatis integration with Spring Native feature
2+
3+
[![Java CI](https://github.com/kazuki43zoo/mybatis-spring-native/actions/workflows/ci.yaml/badge.svg)](https://github.com/kazuki43zoo/mybatis-spring-native/actions/workflows/ci.yaml)
4+
[![Samples](https://github.com/kazuki43zoo/mybatis-spring-native/actions/workflows/samples.yaml/badge.svg)](https://github.com/kazuki43zoo/mybatis-spring-native/actions/workflows/samples.yaml)
5+
6+
![mybatis-spring](http://mybatis.github.io/images/mybatis-logo.png)
7+
8+
The project that the MyBatis integration with Spring Native feature.
9+
10+
## Requirements
11+
12+
* Java 11+
13+
* [GraalVM](https://github.com/graalvm/graalvm-ce-builds/releases)
14+
* [Spring Boot](https://github.com/spring-projects/spring-boot) 2.6.3+
15+
* [Spring Native](https://github.com/spring-projects-experimental/spring-native) 0.11.2+
16+
* [MyBatis Spring](https://github.com/mybatis/spring) 2.0.7+
17+
* [MyBatis Spring Boot](https://github.com/mybatis/spring-boot-starter) 2.2.2+
18+
19+
## Essentials
20+
21+
* [Reference documentation](docs/src/site/markdown/index.md)
22+
23+
## How to build
24+
25+
> **NOTE: Pre Conditions**
26+
>
27+
> Need to following environment variables are defined.
28+
>
29+
> * `JAVA_HOME`
30+
> * `GRAALVM_HOME`
31+
32+
### All modules
33+
34+
```
35+
./mvnw -Pnative clean package
36+
```
37+
> **WARNING:**
38+
>
39+
> **Building all modules takes long time.**
40+
41+
42+
### Core module and specific sample module
43+
44+
```
45+
./mvnw -pl core,samples/simple -Pnative clean package
46+
```
47+
48+
> **NOTE:**
49+
>
50+
> Please replace the 'simple' part on above example to sample's suffix value(e.g. xml, sqlprovider and more) that you want to build.
51+
52+
### Extension module and specific sample module
53+
54+
```
55+
./mvnw -pl core,extensions,samples/thymeleaf -Pnative clean package
56+
```
57+
58+
## How to run
59+
60+
### Run with Native Image
61+
62+
63+
```
64+
./samples/simple/target/mybatis-spring-native-sample-simple
65+
```
66+
67+
```
68+
2022-01-22 13:45:10.453 INFO 2265 --- [ main] o.s.nativex.NativeListener : AOT mode enabled
69+
70+
. ____ _ __ _ _
71+
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
72+
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
73+
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
74+
' |____| .__|_| |_|_| |_\__, | / / / /
75+
=========|_|==============|___/=/_/_/_/
76+
:: Spring Boot :: (v2.6.3)
77+
78+
2022-01-22 13:45:10.455 INFO 2265 --- [ main] s.s.MybatisSpringNativeSampleApplication : Starting MybatisSpringNativeSampleApplication v0.1.0-SNAPSHOT using Java 17.0.1 on fv-az136-971 with PID 2265 (/home/runner/work/mybatis-spring-native/mybatis-spring-native/samples/simple/target/mybatis-spring-native-sample-simple started by runner in /home/runner/work/mybatis-spring-native/mybatis-spring-native)
79+
2022-01-22 13:45:10.455 INFO 2265 --- [ main] s.s.MybatisSpringNativeSampleApplication : No active profile set, falling back to default profiles: default
80+
2022-01-22 13:45:10.487 INFO 2265 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
81+
2022-01-22 13:45:10.491 INFO 2265 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
82+
2022-01-22 13:45:10.496 INFO 2265 --- [ main] s.s.MybatisSpringNativeSampleApplication : Started MybatisSpringNativeSampleApplication in 0.054 seconds (JVM running for 0.056)
83+
2022-01-22 13:45:10.497 INFO 2265 --- [ main] s.s.MybatisSpringNativeSampleApplication : New city: City{id=4, name='NYC', state='NY', country='USA'}
84+
2022-01-22 13:45:10.497 INFO 2265 --- [ main] s.s.MybatisSpringNativeSampleApplication : City{id=1, name='San Francisco', state='CA', country='USA'}
85+
2022-01-22 13:45:10.497 INFO 2265 --- [ main] s.s.MybatisSpringNativeSampleApplication : City{id=2, name='Boston', state='MA', country='USA'}
86+
2022-01-22 13:45:10.497 INFO 2265 --- [ main] s.s.MybatisSpringNativeSampleApplication : City{id=3, name='Portland', state='OR', country='USA'}
87+
2022-01-22 13:45:10.497 INFO 2265 --- [ main] s.s.MybatisSpringNativeSampleApplication : City{id=4, name='NYC', state='NY', country='USA'}
88+
2022-01-22 13:45:10.498 INFO 2265 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
89+
2022-01-22 13:45:10.499 INFO 2265 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
90+
```
91+
92+
### Run with executable jar
93+
94+
```
95+
./samples/simple/target/mybatis-spring-native-sample-simple-exec.jar
96+
```
97+
98+
```
99+
2022-01-22 13:45:14.191 INFO 2305 --- [ main] o.s.nativex.NativeListener : AOT mode disabled
100+
101+
. ____ _ __ _ _
102+
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
103+
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
104+
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
105+
' |____| .__|_| |_|_| |_\__, | / / / /
106+
=========|_|==============|___/=/_/_/_/
107+
:: Spring Boot :: (v2.6.3)
108+
109+
2022-01-22 13:45:14.295 INFO 2305 --- [ main] s.s.MybatisSpringNativeSampleApplication : Starting MybatisSpringNativeSampleApplication v0.1.0-SNAPSHOT using Java 17.0.1 on fv-az136-971 with PID 2305 (/home/runner/work/mybatis-spring-native/mybatis-spring-native/samples/simple/target/mybatis-spring-native-sample-simple-0.1.0-SNAPSHOT-exec.jar started by runner in /home/runner/work/mybatis-spring-native/mybatis-spring-native)
110+
2022-01-22 13:45:14.296 INFO 2305 --- [ main] s.s.MybatisSpringNativeSampleApplication : No active profile set, falling back to default profiles: default
111+
2022-01-22 13:45:15.349 INFO 2305 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
112+
2022-01-22 13:45:15.578 INFO 2305 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
113+
2022-01-22 13:45:15.718 INFO 2305 --- [ main] s.s.MybatisSpringNativeSampleApplication : Started MybatisSpringNativeSampleApplication in 1.892 seconds (JVM running for 2.406)
114+
2022-01-22 13:45:15.774 INFO 2305 --- [ main] s.s.MybatisSpringNativeSampleApplication : New city: City{id=4, name='NYC', state='NY', country='USA'}
115+
2022-01-22 13:45:15.804 INFO 2305 --- [ main] s.s.MybatisSpringNativeSampleApplication : City{id=1, name='San Francisco', state='CA', country='USA'}
116+
2022-01-22 13:45:15.805 INFO 2305 --- [ main] s.s.MybatisSpringNativeSampleApplication : City{id=2, name='Boston', state='MA', country='USA'}
117+
2022-01-22 13:45:15.805 INFO 2305 --- [ main] s.s.MybatisSpringNativeSampleApplication : City{id=3, name='Portland', state='OR', country='USA'}
118+
2022-01-22 13:45:15.806 INFO 2305 --- [ main] s.s.MybatisSpringNativeSampleApplication : City{id=4, name='NYC', state='NY', country='USA'}
119+
2022-01-22 13:45:15.816 INFO 2305 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
120+
2022-01-22 13:45:15.823 INFO 2305 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
121+
```
122+
123+
## How to install integrating modules and use it on your application
124+
125+
Install the `mybatis-spring-native-core` (and `mybatis-spring-native-extensions`) on your local repository as follows:
126+
127+
```
128+
./mvnw -pl core,extensions clean install
129+
```
130+
131+
Specify the `mybatis-spring-native-core` and `mybatis-spring-boot-starter` on `pom.xml` as follows:
132+
133+
```xml
134+
<dependencies>
135+
<dependency>
136+
<groupId>org.mybatis.spring.native</groupId>
137+
<artifactId>mybatis-spring-native-core</artifactId>
138+
<version>0.1.0-SNAPSHOT</version>
139+
</dependency>
140+
<dependency>
141+
<groupId>org.mybatis.spring.boot</groupId>
142+
<artifactId>mybatis-spring-boot-starter</artifactId>
143+
<version>2.2.2</version>
144+
</dependency>
145+
</dependencies>
146+
```
147+
148+
If you use other extension modules provided by mybatis, please specify the `mybatis-spring-native-extensions` instead of `mybatis-spring-native-core`.
149+
150+
```xml
151+
<dependencies>
152+
<dependency>
153+
<groupId>org.mybatis.spring.native</groupId>
154+
<artifactId>mybatis-spring-native-extensions</artifactId>
155+
<version>0.1.0-SNAPSHOT</version>
156+
</dependency>
157+
</dependencies>
158+
```
159+
160+
Add snapshot repository when use MyBatis's snapshot modules.
161+
162+
```xml
163+
<repositories>
164+
<repository>
165+
<id>sonatype-oss-snapshots</id>
166+
<name>Sonatype OSS Snapshots Repository</name>
167+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
168+
</repository>
169+
</repositories>
170+
```
171+
172+
## Related Links
173+
174+
* https://spring.io/blog/2021/12/29/go-go-graalvm-with-spring-native-my-adventures-in-native-image-ville
175+
* https://joshlong.com/jl/blogPost/mybatis-and-spring-native.html
176+
177+
## Special Thanks
178+
179+
Thanks for helping this project creation!!
180+
181+
* Josh Long([@joshlong](https://github.com/joshlong))
182+
Josh provided [the first sample application](https://github.com/joshlong/mybatis-spring-native/tree/mybatis-spring).
183+
184+
185+
* Stéphane Nicoll([@snicoll](https://github.com/snicoll))
186+
Stéphane resolved and helped some issues for running MyBatis on native image.

core/format.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright 2022 the original author or authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
19+
<!DOCTYPE Format>
20+
<Format>
21+
<!-- Dummy format file -->
22+
</Format>

core/license.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright ${license.git.copyrightYears} the original author or authors.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

0 commit comments

Comments
 (0)