-
Notifications
You must be signed in to change notification settings - Fork 59
Build Runnable Jar
Wuyi Chen edited this page Jul 3, 2019
·
10 revisions
Before configuring build.gradle
file, you need to check the version of Gradle and make sure the version is > 4.0. Because we need to apply a Gradle plugin called spring-boot-gradle-plugin
to all the sub-projects, that plugin needs the Gradle version is > 4.0.
For checking the gradle version, you can use the following command:
gradle -v
The key point of modifying build.gradle
is applying the gradle plugin pring-boot-gradle-plugin
. With this plugin, you don't have to specify where is the class has the main function, that plugin will automatically figure out where it is.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.6.RELEASE") // include the spring-boot-gradle-plugin
}
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot' // apply the spring-boot-gradle-plugin
apply plugin: 'io.spring.dependency-management'
bootJar {
baseName = 'root-project-name'
version = '1.0.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("org.springframework.boot:spring-boot-starter-test")
}
If your project consists several sub-projects and each sub-project is a microservice. You need to apply the spring-boot-gradle-plugin
to sub-project level rather root project level.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.6.RELEASE") // include the spring-boot-gradle-plugin
}
}
apply plugin: 'io.spring.dependency-management' // apply the plugin in root project level
subprojects{
apply plugin: 'org.springframework.boot' // apply the pluin in sub-project level
// omit other lines
}
- Overview
- Getting Started
-
Technical Essentials
- Autowired
- SpringData JPA
- Configuration File Auto-loading
- Configuration Encryption
- Service Discovery with Eureka
- Resiliency Patterns with Hystrix
- Configure Hystrix
- Service Gateway with Zuul
- Zuul Filters
- Protect Service with Spring Security and OAuth2
- Use JWT as Access Token
- Store Clients and Users' Credentials to DB
- Integrate with Message Queue (Kafka)
- Integrate with Redis
- Tune Logging
- Log Aggregation
- Send Trace to Zipkin
- Build Runnable Jar
- Core Application Logic
- Components