2017-12-07 13 views
0

私は春のブートに慣れておらず、Springのサイトで実証されているいくつかの例を試しています。 この単純な例を試してみると、上記のエラーが表示されます - https://spring.io/guides/gs/relational-data-access/Springブート:エラー - 「メソッドがjdbcTemplateから実行され、DataAccessExceptionが見つからない」

「JdbcTemplate型のメソッドexecute(String)が欠落している型のDataAccessExceptionを参照しています」というコンパイラエラーが発生しました。

イメージ -

https://i.stack.imgur.com/8PL0m.jpg

私は春-TX/spring.transationsな瓶を添付することが示唆されたこの問題を取り除くために他のリソースを検索しました。私の場合は何も働いていません。誰もができれば

<parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.5.9.RELEASE</version> 
    </parent> 

    <properties> 
     <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> 
     <dependency> 
      <groupId>com.jayway.jsonpath</groupId> 
      <artifactId>json-path</artifactId> 
      <scope>test</scope> 
     </dependency> 

     <!-- Added for COnsuming Restful services guide --> 
     <dependency> 
      <groupId>com.fasterxml.jackson.core</groupId> 
      <artifactId>jackson-databind</artifactId> 
     </dependency> 

     <!-- Following three Added for Validating form validate with spring --> 

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

     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-validator</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.apache.tomcat.embed</groupId> 
      <artifactId>tomcat-embed-el</artifactId> 
     </dependency> 

     <!-- Following two are Added for relational data access using spring guide --> 

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

     <dependency> 
      <groupId>com.h2database</groupId> 
      <artifactId>h2</artifactId> 
     </dependency> 

     <!-- https://mvnrepository.com/artifact/org.springframework/spring-tx --> 


    </dependencies> 

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

    <pluginRepositories> 
     <pluginRepository> 
      <id>spring-releases</id> 
      <url>https://repo.spring.io/libs-release</url> 
     </pluginRepository> 
    </pluginRepositories> 
</project> 

が私を助けてください -

のpom.xmlには、以下の依存を持っていますか?ありがとう、トン! 春・ブート・スターター-JDBCのためのMavenの依存関係ツリーの更新

com.kurshit.springrest:SpringRest:war:0.0.1-SNAPSHOT 
+- org.springframework.boot:spring-boot-starter-web:jar:1.5.9.RELEASE:compile 
| +- org.springframework.boot:spring-boot-starter:jar:1.5.9.RELEASE:compile 
| | +- org.springframework.boot:spring-boot:jar:1.5.9.RELEASE:compile 
| | | +- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
| | | \- (org.springframework:spring-context:jar:4.3.13.RELEASE:compile - omitted for duplicat 
| | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.9.RELEASE:compile 
| | | \- (org.springframework.boot:spring-boot:jar:1.5.9.RELEASE:compile - omitted for duplica 
| | +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.9.RELEASE:compile 
| | | +- ch.qos.logback:logback-classic:jar:1.1.11:compile 
| | | | +- ch.qos.logback:logback-core:jar:1.1.11:compile 
| | | | \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.6.6; omitted for 
| | | +- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile 
| | | | \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.7.22; omitted for 
| | | +- org.slf4j:jul-to-slf4j:jar:1.7.25:compile 
| | | | \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.7.22; omitted for 
| | | \- org.slf4j:log4j-over-slf4j:jar:1.7.25:compile 
| | |  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.7.22; omitted for 
| | +- org.springframework:spring-core:jar:4.3.13.RELEASE:compile 
| | \- org.yaml:snakeyaml:jar:1.17:runtime 
| +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.9.RELEASE:compile 
| | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.23:compile 
| | | \- org.apache.tomcat:tomcat-annotations-api:jar:8.5.23:compile 
| | +- (org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.23:compile - omitted for duplicate) 
| | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.23:compile 
| |  \- (org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.23:compile - omitted for duplicate 
| +- (org.hibernate:hibernate-validator:jar:5.3.6.Final:compile - omitted for duplicate) 
| +- (com.fasterxml.jackson.core:jackson-databind:jar:2.8.10:compile - omitted for duplicate) 
| +- org.springframework:spring-web:jar:4.3.13.RELEASE:compile 
| | +- org.springframework:spring-aop:jar:4.3.13.RELEASE:compile 
| | | +- (org.springframework:spring-beans:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
| | | \- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
| | +- org.springframework:spring-beans:jar:4.3.13.RELEASE:compile 
| | | \- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
| | +- org.springframework:spring-context:jar:4.3.13.RELEASE:compile 
| | | +- (org.springframework:spring-aop:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
| | | +- (org.springframework:spring-beans:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
| | | +- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
| | | \- (org.springframework:spring-expression:jar:4.3.13.RELEASE:compile - omitted for dupli 
| | \- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
| \- org.springframework:spring-webmvc:jar:4.3.13.RELEASE:compile 
|  +- (org.springframework:spring-aop:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
|  +- (org.springframework:spring-beans:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
|  +- (org.springframework:spring-context:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
|  +- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
|  +- org.springframework:spring-expression:jar:4.3.13.RELEASE:compile 
|  | \- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
|  \- (org.springframework:spring-web:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
+- org.springframework.boot:spring-boot-starter-test:jar:1.5.9.RELEASE:test 
| +- org.springframework.boot:spring-boot-test:jar:1.5.9.RELEASE:test 
| | \- (org.springframework.boot:spring-boot:jar:1.5.9.RELEASE:test - omitted for duplicate) 
| +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.9.RELEASE:test 
| | +- (org.springframework.boot:spring-boot-test:jar:1.5.9.RELEASE:test - omitted for duplicat 
| | \- (org.springframework.boot:spring-boot-autoconfigure:jar:1.5.9.RELEASE:test - omitted for 
| +- (com.jayway.jsonpath:json-path:jar:2.2.0:test - omitted for duplicate) 
| +- junit:junit:jar:4.12:test 
| | \- (org.hamcrest:hamcrest-core:jar:1.3:test - version managed from 1.1; omitted for duplica 
| +- org.assertj:assertj-core:jar:2.6.0:test 
| +- org.mockito:mockito-core:jar:1.10.19:test 
| | +- (org.hamcrest:hamcrest-core:jar:1.3:test - version managed from 1.1; omitted for duplica 
| | \- org.objenesis:objenesis:jar:2.1:test 
| +- org.hamcrest:hamcrest-core:jar:1.3:test 
| +- org.hamcrest:hamcrest-library:jar:1.3:test 
| | \- (org.hamcrest:hamcrest-core:jar:1.3:test - version managed from 1.1; omitted for duplica 
| +- org.skyscreamer:jsonassert:jar:1.4.0:test 
| | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test 
| +- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - scope updated from test; omit 
| \- org.springframework:spring-test:jar:4.3.13.RELEASE:test 
|  \- (org.springframework:spring-core:jar:4.3.13.RELEASE:test - omitted for duplicate) 
+- com.jayway.jsonpath:json-path:jar:2.2.0:test 
| +- net.minidev:json-smart:jar:2.2.1:test 
| | \- net.minidev:accessors-smart:jar:1.1:test 
| |  \- org.ow2.asm:asm:jar:5.0.3:test 
| \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.7.16; scope updated from t 
+- com.fasterxml.jackson.core:jackson-databind:jar:2.8.10:compile 
| +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile 
| \- com.fasterxml.jackson.core:jackson-core:jar:2.8.10:compile 
+- org.springframework.boot:spring-boot-starter-thymeleaf:jar:1.5.9.RELEASE:compile 
| +- (org.springframework.boot:spring-boot-starter:jar:1.5.9.RELEASE:compile - omitted for dupli 
| +- (org.springframework.boot:spring-boot-starter-web:jar:1.5.9.RELEASE:compile - omitted for d 
| +- org.thymeleaf:thymeleaf-spring4:jar:2.1.6.RELEASE:compile 
| | +- org.thymeleaf:thymeleaf:jar:2.1.6.RELEASE:compile 
| | | +- ognl:ognl:jar:3.0.8:compile 
| | | +- org.javassist:javassist:jar:3.21.0-GA:compile (version managed from 3.16.1-GA) 
| | | +- org.unbescape:unbescape:jar:1.1.0.RELEASE:compile 
| | | \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.6.6; omitted for dup 
| | \- org.slf4j:slf4j-api:jar:1.7.25:compile 
| \- nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:jar:1.4.0:compile 
|  +- org.codehaus.groovy:groovy:jar:2.4.13:compile (version managed from 2.4.3) 
|  \- (org.thymeleaf:thymeleaf:jar:2.1.6.RELEASE:compile - version managed from 2.1.4.RELEASE; 
+- org.hibernate:hibernate-validator:jar:5.3.6.Final:compile 
| +- javax.validation:validation-api:jar:1.1.0.Final:compile 
| +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile (version managed from 3.3.0.Final) 
| \- com.fasterxml:classmate:jar:1.3.4:compile (version managed from 1.3.1) 
+- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.23:compile 
+- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.9.RELEASE:compile 
| +- (org.springframework.boot:spring-boot-starter:jar:1.5.9.RELEASE:compile - omitted for dupli 
| +- org.apache.tomcat:tomcat-jdbc:jar:8.5.23:compile 
| | \- org.apache.tomcat:tomcat-juli:jar:8.5.23:compile 
| \- org.springframework:spring-jdbc:jar:4.3.13.RELEASE:compile 
|  +- (org.springframework:spring-beans:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
|  +- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
|  \- org.springframework:spring-tx:jar:4.3.13.RELEASE:compile 
|  +- (org.springframework:spring-beans:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
|  \- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate) 
\- com.h2database:h2:jar:1.4.196:compile 
+0

'mvn dependency:tree -Dverbose'を実行して結果を投稿できますか? –

+0

必要な依存関係があるので、これは日食の問題だと思われます。 1. mavenを使用してコードをコンパイルし、問題がeclipseにのみ存在することを確認します。 2. eclipseでmaven依存関係を更新する(残念ながら、その方法を覚えていない) 3. Eclipseで表示される依存関係をMavenからの依存関係と比較する。 –

+0

私はmavenリポジトリでsring-txの2つのバージョンの依存関係の競合がありました。他の人物を削除すると、そのトリックが行われ、問題が解決されました。貴重な洞察をいただき、ありがとうございます。 – Kurshit

答えて

0

には、以下の依存関係を追加します(あなたの春のブートバージョンと互換性があるようにバージョンを調整する必要がある場合があります)

<!-- https://mvnrepository.com/artifact/org.springframework/spring-tx --> 
<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-tx</artifactId> 
    <version>5.0.2.RELEASE</version> 
</dependency> 

編集: mavenリポジトリから競合する依存関係を削除すると、このコンパイルエラーがなくなりました。

+0

OPはSpring Boot 1.59を使用するので、おそらく4.xバージョンを使用するべきです。それはどんなやり方で引っ張られるべきなのだろうか? –

+0

JDBCスターターがトランザクションディープをもたらすかどうかは不明です。ツリーの出力が何を示すかを見てみましょう。 – PaulNUK

+1

spring-jdbcはhttp://central.maven.org/maven2/org/springframework/spring-jdbc/4.3.13.RELEASE/spring-jdbc-4.3.13.RELEASE.pom –

関連する問題