先贴出build.gradle
apply plugin: 'java'
sourceCompatibility = 1.8
jar {
manifest {
attributes 'Main-Class': 'com.sdp.app.Main'
}
}
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.springframework', name: 'spring-core', version: '4.1.6.RELEASE'
compile group: 'org.springframework', name: 'spring-context-support', version: '4.1.6.RELEASE'
}
task download(type: Copy) {
from configurations.runtime
into 'lib'
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
首先,要使用java插件,然后指定jar的manifest属性Main-Class。