2

Dropwizard と Gradle をビルド システムとして使用して、単純なマイクロサービスを作成しようとしています。データベースはなく、REST エンドポイントのみを公開します。

だから私はコントローラーを持っています:

@Path("/domainurl/")
@Produces(MediaType.APPLICATION_JSON)
public class SimpleController {

    @GET
    public Example resourceExample() {
        return new Example("something");
    }
}

私のアプリケーションのメインクラス:

public class Application extends Application<MyConfiguration> {

    @Override
    public void run(MyConfiguration configuration, Environment environment) throws Exception {
        final SimpleCOntroller controller = new SimpleController();
        environment.jersey().register(controller);
    }

    public static void main(String[] args) throws Exception {
        new Application().run(args);
    }
}

例は、1 つの文字列プロパティを持つ単純な値オブジェクトです。MyConfiguration は現時点では空のクラスです。

そしてbuild.gradle:

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.0'
    }
}

apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'

mainClassName = "com.example.Application"

//
dependencies
//

run {
    args 'server', './src/config/microservice.yml'
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.1'
}

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

しかし、ビルド後、次のように入力すると:

java -jar MyApp.jar

私はまだ得ています:

Error: Could not find or load main class com.example.Application

何か案は?

4

2 に答える 2