使用zip64 true
不会创建可用的jar文件。虽然Manifest.mf的文件,结构和位置与先前构建的文件,结构和位置完全相同,但它无法在该jar中找到主类。
真正的问题是:我不需要在最终版本中使用sonarqube或gatling(与测试相关),但AFAIK无法排除插件。
" fatJar" -task用于创建jar。
非常感谢任何形式的帮助。
plugins {
id "org.sonarqube" version "2.2.1"
id "com.github.lkishalmi.gatling" version "0.4.1"
}
// Run in terminal with "gradle sonarqube"
sonarqube {
properties {
property "sonar.projectName", "asd"
property "sonar.projectKey", "org.sonarqube:java-gradle-simple"
property "sonar.host.url", "http://asd"
property "sonar.login", "asd"
property "sonar.password", "asd"
}
}
// Run in terminal with "gradle gatlingrun", start the application before.
gatling {
logLevel 'ERROR'
simulations = {
include "**/LoginAndSync.scala"
}
}
group 'asd'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
task fatJar(type: Jar) {
//zip64 true
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Implementation-Version': version,
'Main-Class': 'application.Asd'
}
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.4.1.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '1.4.1.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '1.4.1.RELEASE'
compile group: 'org.springframework', name: 'spring-orm', version: '4.3.3.RELEASE'
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.5'
compile group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.80'
compile group: 'io.gatling.highcharts', name: 'gatling-charts-highcharts', version: '2.2.3'
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '1.4.1.RELEASE'
testCompile group: 'com.h2database', name: 'h2', version: '1.4.193'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.springframework.security', name: 'spring-security-test', version: '4.0.0.RELEASE'
}
这是我得到的例外:
xecution failed for task ':fatJar'.
> archive contains more than 65535 entries.
To build this archive, please enable the zip64 extension.
See: https://docs.gradle.org/3.3/dsl/org.gradle.api.tasks.bundling.Zip.html#org.gradle.api.tasks.bundling.Zip:zip64
答案 0 :(得分:0)
感谢M.Deinum,我做了一个新的方法:
我在// Using controller and action
var urlHelper = new UrlHelper(new System.Web.Routing.RequestContext(this.HttpContext, this.RouteData));
var url = urlHelper.Action("View", "Videos", new System.Web.Routing.RouteValueDictionary { { "id", 123 } });
// Using controller, action, and route name (similar to @Html.RouteLink())
var urlHelper = new UrlHelper(new System.Web.Routing.RequestContext(this.HttpContext, this.RouteData));
var url = urlHelper.RouteUrl("RouteName", new System.Web.Routing.RouteValueDictionary { { "controller", "Videos" }, { "action", "View" }, { "id", 123 } });
build.gradle
现在可以在控制台中使用plugins {
id 'org.springframework.boot' version '1.5.1.RELEASE'
}
来获取正在运行的jar,可以在gradle build
中找到。