繁体   English   中英

如何使用gradle创建Dropwizard项目?

[英]How to create a Dropwizard project with gradle?

我在使用Idea IntelliJ的Linux机器上,我想用gradle创建一个Dropwizard项目。 使用Maven原型,此工作将非常容易。

mvn archetype:generate 
-DarchetypeGroupId=io.dropwizard.archetypes 
-DarchetypeArtifactId=java-simple 
-DarchetypeVersion=[REPLACE ME WITH A VALID DROPWIZARD VERSION]

对于gradle,我正在努力前进。 当我查看其他帖子时,我想知道我所做的是否正确:

// Needed Instead of the Shade plug in 
plugins {
    id 'com.github.johnrengelman.shadow' version '2.0.1'
}

version '1.0-SNAPSHOT'
group 'org.example.sampleName'
description 'Sample Dropwizard REST '

apply plugin: 'java'
apply plugin: 'application'

repositories {
    mavenCentral()
}

dependencies {
    compile 'io.dropwizard:dropwizard-core:1.2.0'

    testCompile 'junit:junit:4.12'
}

mainClassName = 'org.example.sampleName.SampleApplication'

run {
    args = ['server', 'config.yml']
}

shadowJar {
    mergeServiceFiles()
    exclude 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.SF'

}

jar {
    manifest {
        attributes 'Main-Class': mainClassName
    }
}

然后我只运行gradle shadowJar ,然后运行java -jar build/SampleApplication.jar server config.yml 这个对吗? testCompile 'junit:junit:4.12'足以进行单元测试?

您可以使用以下Yeoman生成器:

https://www.npmjs.com/package/generator-dropwizard-gradle

如果已安装npm。

testCompile 'junit:junit:4.12'就足够了,是的。

您也可以在github上搜索示例,例如: https : //github.com/kishaningithub/dropwizard-gradle

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM