1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

IntellijIDEA+SpringBoot+Gradle+MyBatisの設定例

Posted at

属性もりもり。

IDEAはCommunityの2019.3.1
Javaのバージョンは11
SpringBootは2.2.4.RELEASE
Gradleは5.2.1
MyBatisは3.5.2
(mybatis-spring-boot-starter:2.1.0)

build.gradle
group 'com.xxx.xxx'
version '0.1-SNAPSHOT'

// Spring Boot ver:2.2.4
buildscript {
    def springBootVersion = '2.2.4.RELEASE'
    repositories { mavenCentral() }
    dependencies {
        classpath ("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

// Javaプラグイン
apply plugin:'java'
// 各種IDEの設定ファイルを出力するGradleプラグインの設定
apply plugin:'idea'
apply plugin:'eclipse'
// SpringBoot関連のプラグイン
apply plugin:'org.springframework.boot'
apply plugin:'io.spring.dependency-management'
// warファイルを出力する
apply plugin: 'war'

// Javaバージョン
def javaVersion = JavaVersion.VERSION_11
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

// 依存ライブラリ取得先リポジトリ
repositories { mavenCentral() }
// 依存ライブラリ
dependencies {
    // SpringBoot
    compile("org.postgresql:postgresql")
    compile("org.springframework.boot:spring-boot-devtools")
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-jdbc")
    testCompile("org.springframework.boot:spring-boot-starter-test")
    // JUnit
    testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.2.0'
    testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.2.0'
    testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.2.0'
    // GSON
    compile("com.google.code.gson:gson")
    // myBatis
    compile("org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.0")
    compile("ch.qos.logback:logback-classic")
    testCompile("org.mybatis.spring.boot:mybatis-spring-boot-starter-test:2.1.0")
}
test {
    // gradle buildの時にJUnit5を使うようにする
    useJUnitPlatform()
    // テストの並列実行スレッド数
    maxParallelForks = 4
    filter{
        // 表に出せないやつなので伏せる
    }
}

// リリースバージョンをgradle.propertiesから取得し設定
def applicationVersion = project.properties['release.version']
version = applicationVersion
def springBootApplicationName = 'hogehoge'
bootJar {
    archiveBaseName  = springBootApplicationName
    version = applicationVersion
}
bootWar {
    archiveBaseName  = springBootApplicationName
    version = applicationVersion
}

属性もりもりで、ご参考になれば幸いです。

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?