2017-01-26 12 views
3

私は春に新しく、maven-web Java 1.8デモ用のspring intializrからjarをダウンロードしました。私は抽出し、main()ファイルを実行するためにSTSにインポートし、私は以下の例外を取得します。ある人がこれに対する解決策を教えてくれますか?Springブートサンプル:組み込みコンテナエラーを開始することができません

ソリューション私はウェブから試みたが、は動作しませんでした: - をポンポンするためにHibernateバリデータの依存関係を追加しようとしました -

スタックトレースをPOM、スプリング・ブート・スターター・Tomcatの依存関係を追加しようとしました:

2017-01-26 12:19:32.587 INFO 3816 --- [   main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot[email protected]2e4b8173: startup date [Thu Jan 26 12:19:32 EST 2017]; root of context hierarchy 
2017-01-26 12:19:36.442 WARN 3816 --- [   main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.HttpEncodingAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.http.encoding-org.springframework.boot.autoconfigure.web.HttpEncodingProperties': Initialization of bean failed; nested exception is javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath. 
2017-01-26 12:19:36.454 ERROR 3816 --- [   main] o.s.b.d.LoggingFailureAnalysisReporter : 

*************************** 
APPLICATION FAILED TO START 
*************************** 

Description: 

The Bean Validation API is on the classpath but no implementation could be found 

Action: 

Add an implementation, such as Hibernate Validator, to the classpath 

の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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.example</groupId> 
    <artifactId>demo</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>demo</name> 
    <description>Demo project for Spring Boot</description> 

    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.4.3.RELEASE</version> 
     <relativePath/> <!-- lookup parent from repository --> 
    </parent> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
     <java.version>1.8</java.version> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-test</artifactId> 
      <scope>test</scope> 
     </dependency> 

    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
      </plugin> 
     </plugins> 
    </build> 


</project> 

アプリケーションファイル:

package com.example; 

import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 

@SpringBootApplication 
public class DemoApplication { 

    public static void main(String[] args) { 
     SpringApplication.run(DemoApplication.class, args); 
    } 
} 
+0

のHibernate Validatorはバネブートスタータweb'は次 'によって推移提供されるべきです。 Mavenがダウンロードしたときにjarファイルが破損していたと思います。 Mavenのキャッシュをクリアしてから、アプリケーションを再構築してください。 –

+0

ありがとう@AndyWilkinson。私はmaven cleanを使用して再構築しましたが、同じ結果が得られました。その後、私は.m2フォルダからすべてのフォルダを削除しました(私は長い間mavenを使用していましたので、たくさんのフォルダを持っていました)。私は、この問題は既存のjarバージョンで起こる可能性があると思います。 –

+0

私はまたすべてを取り除き、新鮮なものから始めなければならなかった。 pomファイルに必要な依存関係を追加するだけで何もできませんでした。 – James

答えて

2

出力が言うように、あなたがする必要があります。

があるので、クラスパス

には、そのようなHibernateバリとして、実装を追加します。 Mavenを使用しています。つまり、pom.xmlの依存関係にHibernate Validatorを追加する必要があります。

0

私は同じ問題に出会い、それがによって.m2

  • COM \ fasterxmlの下でこれらの2つのフォルダを削除解消 - >それはTypeResovler問題を解決します削除します。
  • org \ springframework - >削除すると、バリデーターの不足が解決されます 問題です。

プログラムが動作します。

+0

これらの手順の後に機能しませんでした。 :( – Goura

1

リリースバージョン1.5.9のSpring Bootで同じ問題が発生しました。

<dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-validator</artifactId> 
    <version>5.3.6.Final</version> 
</dependency> 

あなたは春のブートpom.xmlファイル(春・ブートdependencies-のプロパティ]セクションの下に依存関係のバージョンを使用することができます:あなたはMavenののpom.xmlに以下を追加する必要があり、Jim Kileyによって答えに追加するには 1.5.9.RELEASE.pom):

経路の下に位置
<hibernate-validator.version>5.3.6.Final</hibernate-validator.version> 

/.m2/repository/org/springframework/boot/spring-boot-dependencies/1.5.9.RELEASE/spring-boot-dependencies-1.5.9.RELEASE.pom 
関連する問題