2017-01-06 2 views
0

私はこのDropwizardのこと、そしてJAVA全体については新しいです。私は、基本的なDropwizardプロジェクト(Hibernateを通してMySQLデータベースとの接続を持つ)を作成しようとしました。私は同じもののEclipse IDEを使用しています。私はすべての手順をTに従いましたが、このコマンドをコンソールで入力する際に​​ - > java -jar target/hotel2-0.0.1-SNAPSHOT.jarサーバーconfig.ymlを入力してください。私は次のエラーを取得する: - 以下Dropwizard:config.ymlにエラーがあります

config.yml has an error: 
* Failed to parse configuration at: logging; Can not instantiate value of type [simple type, class io.dropwizard.logging.LoggingFactory] from String value (''); no single-String constructor/factory method at [Source: N/A; line: -1, column: -1] (through reference chain: com.drivedge.hotel2.HotelMgntConfiguration["logging"]) 

は私のpom.xmlとconfig.ymlファイルのコピーです:

config.yml -

## Configuration file for Hotel2 application. 
--- 
# User login. 
logging: 
login: javaeeeee 
# User password. 
password: crimson 

#Server configuration. 
server: 
    applicationConnectors: 
     - type: http 
      port: 9090 
     - type: https 
      port: 9090 
      keyStorePath: hotel2.keystore 
      keyStorePassword: crimson 

# Database settings. 
database: 
    # the name of the JDBC driver, mysql in our case 
    driverClass: com.mysql.jdbc.Driver 
    # the username 
    user: root 
    # the password 
    password: drivedge12 
    # the JDBC URL; the database is called Hotel2 
    url: jdbc:mysql://localhost:3306/hotelmanagement 

のpom.xml -

<?xml version="1.0" encoding="UTF-8"?> 
<project 
     xmlns="http://maven.apache.org/POM/4.0.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 

    <modelVersion>4.0.0</modelVersion> 
    <prerequisites> 
     <maven>3.0.0</maven> 
    </prerequisites> 

    <groupId>com.drivedge</groupId> 
    <artifactId>hotel2</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>HotelMgnt</name> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
     <dropwizard.version>0.8.2</dropwizard.version> 
     <mainClass>com.drivedge.hotel2.HotelMgntApplication</mainClass> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>io.dropwizard</groupId> 
      <artifactId>dropwizard-core</artifactId> 
      <version>${dropwizard.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>io.dropwizard</groupId> 
      <artifactId>dropwizard-hibernate</artifactId> 
      <version>${dropwizard.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>5.1.6</version> 
     </dependency> 
     <dependency> 
    <groupId>org.eclipse.persistence</groupId> 
    <artifactId>eclipselink</artifactId> 
    <version>2.5.1</version> 
</dependency> 
<dependency> 
    <groupId>org.eclipse.persistence</groupId> 
    <artifactId>javax.persistence</artifactId> 
    <version>2.0.0</version> 
    <scope>compile</scope> 
</dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <artifactId>maven-shade-plugin</artifactId> 
       <version>1.7</version> 
       <configuration> 
        <createDependencyReducedPom>true</createDependencyReducedPom> 
        <transformers> 
         <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> 
         <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
          <mainClass>${mainClass}</mainClass> 
         </transformer> 
         <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> 
        </transformers> 
        <!-- exclude signed Manifests --> 
        <filters> 
         <filter> 
          <artifact>*:*</artifact> 
          <excludes> 
           <exclude>META-INF/*.SF</exclude> 
           <exclude>META-INF/*.DSA</exclude> 
           <exclude>META-INF/*.RSA</exclude> 
          </excludes> 
         </filter> 
        </filters> 
       </configuration> 
       <executions> 
        <execution> 
         <phase>package</phase> 
         <goals> 
          <goal>shade</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <artifactId>maven-jar-plugin</artifactId> 
       <version>2.4</version> 
       <configuration> 
        <archive> 
         <manifest> 
          <addClasspath>true</addClasspath> 
          <mainClass>${mainClass}</mainClass> 
         </manifest> 
        </archive> 
       </configuration> 
      </plugin> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.3.2</version> 
       <configuration> 
        <source>1.7</source> 
        <target>1.7</target> 
       </configuration> 
      </plugin> 
      <plugin> 
       <artifactId>maven-source-plugin</artifactId> 
       <version>2.1.2</version> 
       <executions> 
        <execution> 
         <id>attach-sources</id> 
         <goals> 
          <goal>jar</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <artifactId>maven-javadoc-plugin</artifactId> 
       <version>2.8.1</version> 
       <executions> 
        <execution> 
         <id>attach-javadocs</id> 
         <goals> 
          <goal>jar</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <artifactId>maven-site-plugin</artifactId> 
       <version>3.0</version> 
       <configuration> 
        <reportPlugins> 
         <plugin> 
          <artifactId>maven-project-info-reports-plugin</artifactId> 
          <version>2.4</version> 
          <configuration> 
           <dependencyLocationsEnabled>false</dependencyLocationsEnabled> 
           <dependencyDetailsEnabled>false</dependencyDetailsEnabled> 
          </configuration> 
         </plugin> 
         <plugin> 
          <artifactId>maven-javadoc-plugin</artifactId> 
          <version>2.8.1</version> 
         </plugin> 
        </reportPlugins> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

私の設定ファイル: -

package com.drivedge.hotel2; 

import io.dropwizard.Configuration; 
import com.fasterxml.jackson.annotation.JsonProperty; 
import io.dropwizard.db.DataSourceFactory; 
import javax.validation.Valid; 
import javax.validation.constraints.*; 
//import org.apache.tomcat.jdbc.pool.DataSourceFactory; 

public class HotelMgntConfiguration extends Configuration { 
    /*// /** 
    * A factory used to connect to a relational database management system. 
    * Factories are used by Dropwizard to group together related configuration 
    * parameters such as database connection driver, URI, password etc. 
    */ 

    @NotNull 
    @Valid 
    @JsonProperty 
    private DataSourceFactory database; 

    /** 
    * A getter for the database factory. 
    * 
    * @return An instance of database factory deserialized from the 
    * configuration file passed as a command-line argument to the application. 
    */ 

    public DataSourceFactory getDataSourceFactory() { 
     return database; 
    } 

    public void setDatabase(DataSourceFactory database) { 
     this.database = database; 
    } 
} 

どこが間違っていますか?私はこのDropwizardのすべてのものに本当に新しいです。どんな助けでも大歓迎です!

+0

編集 'config.yml'に問題エントリ' logging: 'がまだ残っています。また、別の質問をし、受け入れられた答えを記入することを検討してください。これはQ&Aサイトです。同じ質問を編集し、有用な回答をマークしないと、あなたを助けてくれた人に賞品を贈ることはできません。 – zloster

+0

あなたは違うが関連する質問がある場合は、同じものを編集するのではなく、新しい質問をしてください。私たちはそれぞれの投稿を独立して立てる必要があります。私はあなたのために編集をロールバックしました。 –

答えて

2

config.ymlからlogging:を削除するか、exampleのようにログを設定してください。

+0

こんにちは、@yanys私はロギングを削除しました:提案されているように、エラーはなくなりました。しかし、私は代わりにこのメッセージを受け取ります - –

+0

こんにちは、@ code.rhyme どのようなメッセージ? –

+0

こんにちは@yanys、私の編集を前の投稿にチェックしてください:) –

関連する問題