2016-07-06 9 views
0

私はかなり勉強しており、REST-Service用のビルドファイルを作成したいと思っています。私がgradleのホームページや他のいくつかのページを紹介した後、私のサービスはJavaベースなので、コマンドgradle init --type=java-projectを使って新しいプロジェクトを開始しました。プロジェクトの構造が作成され、.classファイルをディレクトリに挿入したかったのです。これは私の最初の問題です。私はこの種のプロジェクトのための適切な構造を知らない。この後、私は自分の依存関係に焦点を当てました。私のプロジェクトを構築したいと思うと、技術としてのジャージーの使用に関係しているエラーが発生します。私がeclipseでサービスをコンパイルすると、それは問題なく動作するので、私のコードは動作します。REST-WebサービスのためのGradleファイルの作成

だから私の2つの質問は以下のとおりです。

適切なファイル構造を作成する方法は?私は置く予定はありません

RestWebService 
|--Java Resources 
| |--src 
|  |--com.name.restproject.rest 
|  | |--WebController.java   //contains the jersey REST service 
|  |--com.name.restproject.service 
|  |--ServiceUtil.java   //contains some util methods 
|--Libraries 
| |--Apache Tomcat v7 
| |--asm-3.3.1.jar 
| |--EAR Libraries 
| |--gson-2.5.jar 
| |--jersey-bundle-1.14.jar 
| |--JRE SYSTEM Library 
| |--json-20151123.jar 
| |--Web App Libraries 
|--JavaScript Resources 
|--build 
|--WebContent 
    |--META-INF 
    | |--MANIFEST.MF 
    |--WEB-INF 
     |--lib 
     |--fileName.properties   //File with Data for ServiceUtil.java 
     |--configFile.xml    //File with Confc for ServiceUtil.java 
     |--web.xml      //Config for the REST paths 

:サーブレット/ WAR-コンパイルここで


で問題を解決する方法

は日食の私のプロジェクトの構造であり、 WEB-INFディレクトリの2つのファイル。ビルドのGradleでREST Webサービスを作成したい場合は、私はここでprojectfolderの下でプロジェクトのGradleのファイルである

build.gradle

apply plugin: 'java' 
apply plugin: 'war' 

// In this section you declare where to find the dependencies of your project 
repositories { 
    // Use 'jcenter' for resolving your dependencies. 
    // You can declare any Maven/Ivy/file repository here. 
    mavenCentral() 
} 

// In this section you declare the dependencies for your production and test code 
dependencies { 
    // The production code uses the SLF4J logging API at compile time 
    compile group: 'com.google.code.gson', name: 'gson-parent', version: '2.6' 
    compile group: 'asm', name: 'asm-parent', version: '3.3.1' 
    compile group: 'com.sun.jersey.glassfish.v3.osgi', name: 'jersey-gf-bundle', version: '1.1.4' 
    compile group: 'org.json', name: 'json', version: '20151123' 


    // Declare the dependency for your favourite test framework you want to use in your tests. 
    // TestNG is also supported by the Gradle Test task. Just change the 
    // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add 
    // 'test.useTestNG()' to your build script. 
    testCompile 'junit:junit:4.12' 
} 

答えて

0

/src/main/java/com/name/restproject

を構造を配置していますSpringブートRESTを使用することをお勧めします。

Springブート - RESTful Webサービスの構築:http://spring.io/guides/gs/rest-service/http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-gradle-packaging

:また、あなたは、(デフォルトのビルド構成である)の代わりにJARのWAR、あなたがこのドキュメントに従うことができますを構築したい場合は https://github.com/spring-guides/gs-rest-service/blob/master/initial/build.gradle

はすでにGradleのビルドが含まれています

関連する問題