我目前正在使用Spring Boot在Vaadin中开发一个项目,我想重用另一个项目中的一些存储库而不将该项目作为依赖项添加,但是当我尝试运行该项目时,我收到此错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataCache': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.myproject.vas.aftersales.repository.AfterSalesFileRepository com.myproject.vas.DataCache.afterSalesFileRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'afterSalesFileRepository': Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.springframework.data.repository.core.support.RepositoryFactorySupport.getTargetRepository(Lorg/springframework/data/repository/core/RepositoryInformation;)Ljava/lang/Object;
我在网上搜索了解决方案,并尝试了从切换包到更改依赖关系版本的所有内容......
我的存储库:
@Component
public interface AfterSalesFileRepository extends JpaRepository<AfterSalesFile, Integer> {
@Query("select m from AfterSalesFile m " +
"where m.id=:id and m.status is not 'INACTIVE'")
AfterSalesFile findOne(@Param("id") final Integer id);
}
尝试初始化和使用存储库的类:
@Component
public class DataCache {
@Getter(AccessLevel.PRIVATE)
private CustomerIdentityRepository customerIdentityRepository;
@Autowired
private AfterSalesFileRepository afterSalesFileRepository;
@Autowired
public DataCache(CustomerIdentityRepository customerIdentityRepository) {
this.customerIdentityRepository = customerIdentityRepository;
}
...
public List<AfterSalesFile> getAllAftersales() {
return afterSalesFileRepository.findAll();
}
}
我的数据库配置:
@Configuration
public class DatabaseConfiguration implements EnvironmentAware {
private RelaxedPropertyResolver jpaPropertyResolver;
@Autowired(required = false)
private PersistenceUnitManager persistenceUnitManager;
@Override
public void setEnvironment(Environment environment) {
this.jpaPropertyResolver = new RelaxedPropertyResolver(environment, "spring.jpa.");
}
@Bean
@DependsOn("jdbcTemplate")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
if (persistenceUnitManager != null) {
entityManagerFactoryBean
.setPersistenceUnitManager(persistenceUnitManager);
}
entityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter);
entityManagerFactoryBean.setDataSource(dataSource);
entityManagerFactoryBean.setPackagesToScan("com.myproject.vas.aftersales");
entityManagerFactoryBean.getJpaPropertyMap().putAll(jpaPropertyResolver.getSubProperties("properties."));
Map<String, Object> properties = entityManagerFactoryBean.getJpaPropertyMap();
properties.put("hibernate.ejb.naming_strategy", jpaPropertyResolver.getProperty("hibernate.naming-strategy", SpringNamingStrategy.class.getName()));
properties.put("hibernate.hbm2ddl.auto", jpaPropertyResolver.getProperty("hibernate.ddl-auto", "none"));
properties.put("hibernate.show_sql", jpaPropertyResolver.getProperty("hibernate.show_sql", "false"));
return entityManagerFactoryBean;
}
}
我的主要人物:
@SpringBootApplication
@EnableJpaRepositories(basePackages = {"com.myproject.vas.aftersales.repository"})
@ComponentScan(basePackages = {"com.myproject"})
public class VasApplication {
public static void main(String[] args) {
SpringApplication.run(VasApplication.class, args);
}
}
我的POM:
<?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>
<artifactId>my-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
...
<dependencies>
<!-- Vaadin -->
... Vaadin dependencies
<!-- hibernate dependencies -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<!-- testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.1.6.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<!--<version>4.0.3.RELEASE</version>-->
</dependency>
</dependencies>
</project>
更新
mvn依赖:树
[INFO] --- maven-dependency-plugin:2.9:tree (default-cli) @ infopoint ---
[INFO] com.asadventure:infopoint:jar:0.0.1-SNAPSHOT
[INFO] +- com.asadventure:customer-service:jar:crm-SNAPSHOT:compile
[INFO] | +- org.springframework.cloud:spring-cloud-starter-consul-all:jar:1.0.0.M4:compile
[INFO] | | +- org.springframework.cloud:spring-cloud-starter-consul-config:jar:1.0.0.M4:compile
[INFO] | | | \- org.springframework.cloud:spring-cloud-starter-consul:jar:1.0.0.M4:compile
[INFO] | | \- org.springframework.cloud:spring-cloud-starter-consul-discovery:jar:1.0.0.M4:compile
[INFO] | | \- org.springframework.cloud:spring-cloud-netflix-core:jar:1.0.3.RELEASE:compile
[INFO] | +- com.asadventure:LoggingUtils:jar:1.0.0:compile
[INFO] | | +- org.springframework:spring-webmvc:jar:4.2.3.RELEASE:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.0.22:compile
[INFO] | | \- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.6.3:compile
[INFO] | +- com.asadventure:job-fetch-interface:jar:crm-SNAPSHOT:compile
[INFO] | +- com.asadventure:data-utils:jar:crm-SNAPSHOT:compile
[INFO] | | +- com.datastax.cassandra:cassandra-driver-core:jar:2.1.6:compile
[INFO] | | | \- com.codahale.metrics:metrics-core:jar:3.0.2:compile
[INFO] | | \- org.springframework.data:spring-data-cassandra:jar:1.1.2.RELEASE:compile
[INFO] | | \- org.springframework.data:spring-cql:jar:1.1.2.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-web:jar:1.3.0.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.3.0.RELEASE:compile
[INFO] | | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.0.28:compile
[INFO] | | | +- org.apache.tomcat.embed:tomcat-embed-logging-juli:jar:8.0.28:compile
[INFO] | | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.0.22:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-validation:jar:1.3.0.RELEASE:compile
[INFO] | | | \- org.hibernate:hibernate-validator:jar:5.1.3.Final:compile
[INFO] | | | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | | | \- com.fasterxml:classmate:jar:1.1.0:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-databind:jar:2.6.3:compile
[INFO] | +- org.springframework.cloud:spring-cloud-starter-zuul:jar:1.0.2.RELEASE:compile
[INFO] | | +- org.springframework.cloud:spring-cloud-starter:jar:1.0.1.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-actuator:jar:1.3.0.RELEASE:compile
[INFO] | | | \- org.springframework.boot:spring-boot-actuator:jar:1.3.0.RELEASE:compile
[INFO] | | +- org.springframework.cloud:spring-cloud-starter-hystrix:jar:1.0.2.RELEASE:compile
[INFO] | | | +- com.netflix.hystrix:hystrix-metrics-event-stream:jar:1.4.4:compile
[INFO] | | | \- com.netflix.hystrix:hystrix-javanica:jar:1.4.4:compile
[INFO] | | | +- org.aspectj:aspectjrt:jar:1.8.7:runtime
[INFO] | | | \- com.google.code.findbugs:jsr305:jar:3.0.0:runtime
[INFO] | | +- org.springframework.cloud:spring-cloud-starter-ribbon:jar:1.0.2.RELEASE:compile
[INFO] | | | \- com.netflix.rxjava:rxjava-core:jar:0.20.7:compile
[INFO] | | \- com.netflix.zuul:zuul-core:jar:1.0.28:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-security:jar:1.3.0.RELEASE:compile
[INFO] | | +- org.springframework:spring-aop:jar:4.2.3.RELEASE:compile
[INFO] | | \- org.springframework.security:spring-security-config:jar:4.0.3.RELEASE:compile
[INFO] | +- org.springframework.security.oauth:spring-security-oauth2:jar:2.0.8.RELEASE:compile
[INFO] | | \- commons-codec:commons-codec:jar:1.9:compile
[INFO] | +- org.springframework.security:spring-security-jwt:jar:1.0.3.RELEASE:compile
[INFO] | +- joda-time:joda-time:jar:2.8.1:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:1.3.0.RELEASE:compile
[INFO] | +- org.springframework.hateoas:spring-hateoas:jar:0.19.0.RELEASE:compile
[INFO] | | \- org.slf4j:slf4j-api:jar:1.7.13:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.3:compile
[INFO] | +- org.projectlombok:lombok:jar:1.16.2:compile
[INFO] | +- net.sf.dozer:dozer:jar:5.5.1:compile
[INFO] | +- com.datastax.cassandra:cassandra-driver-dse:jar:2.1.6:compile
[INFO] | +- com.datastax.cassandra:cassandra-driver-mapping:jar:2.1.4:compile
[INFO] | +- com.stratio.cassandra:cassandra-lucene-index-builder:jar:2.2.4.0:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.5.1:compile
[INFO] | | \- org.apache.httpcomponents:httpcore:jar:4.4.1:compile
[INFO] | +- com.google.guava:guava:jar:18.0:compile
[INFO] | +- com.netflix.archaius:archaius-core:jar:0.6.5:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-core:jar:2.6.3:compile
[INFO] | | \- com.google.code.findbugs:annotations:jar:2.0.0:compile
[INFO] | +- commons-configuration:commons-configuration:jar:1.8:compile
[INFO] | | \- commons-lang:commons-lang:jar:2.6:compile
[INFO] | +- com.ecwid.consul:consul-api:jar:1.1.6:compile
[INFO] | | \- com.google.code.gson:gson:jar:2.3.1:compile
[INFO] | +- org.springframework.cloud:spring-cloud-context:jar:1.0.2.RELEASE:compile
[INFO] | | \- org.springframework.security:spring-security-crypto:jar:3.2.7.RELEASE:compile
[INFO] | +- org.springframework.cloud:spring-cloud-commons:jar:1.0.2.RELEASE:compile
[INFO] | +- com.netflix.ribbon:ribbon:jar:2.1.0:compile
[INFO] | | +- com.netflix.ribbon:ribbon-core:jar:2.1.0:compile
[INFO] | | +- com.netflix.ribbon:ribbon-transport:jar:2.1.0:runtime
[INFO] | | | +- io.reactivex:rxnetty-contexts:jar:0.4.9:runtime
[INFO] | | | \- io.reactivex:rxnetty-servo:jar:0.4.9:runtime
[INFO] | | +- com.netflix.hystrix:hystrix-core:jar:1.4.4:compile
[INFO] | | +- javax.inject:javax.inject:jar:1:runtime
[INFO] | | \- io.reactivex:rxnetty:jar:0.4.9:runtime
[INFO] | | +- io.netty:netty-codec-http:jar:4.0.27.Final:runtime
[INFO] | | | +- io.netty:netty-codec:jar:4.0.27.Final:runtime
[INFO] | | | \- io.netty:netty-handler:jar:4.0.27.Final:runtime
[INFO] | | \- io.netty:netty-transport-native-epoll:jar:4.0.27.Final:runtime
[INFO] | +- com.netflix.ribbon:ribbon-httpclient:jar:2.1.0:compile
[INFO] | | +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] | | +- com.sun.jersey:jersey-client:jar:1.13:runtime
[INFO] | | | \- com.sun.jersey:jersey-core:jar:1.13:runtime
[INFO] | | +- com.sun.jersey.contribs:jersey-apache-client4:jar:1.11:runtime
[INFO] | | \- com.netflix.netflix-commons:netflix-commons-util:jar:0.1.1:compile
[INFO] | \- com.netflix.ribbon:ribbon-loadbalancer:jar:2.1.0:compile
[INFO] | \- com.netflix.netflix-commons:netflix-statistics:jar:0.1.1:runtime
[INFO] +- com.asadventure:customer-service-client:jar:docker-SNAPSHOT:compile
[INFO] | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | +- org.springframework:spring-beans:jar:4.2.3.RELEASE:compile
[INFO] | +- org.springframework:spring-context-support:jar:4.2.3.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:4.2.3.RELEASE:compile
[INFO] | +- org.springframework:spring-web:jar:4.2.3.RELEASE:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] | | \- org.codehaus.jackson:jackson-core-asl:jar:1.9.12:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-hateoas:jar:1.3.0.RELEASE:compile
[INFO] | | \- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO] | +- xml-apis:xml-apis:jar:1.3.02:compile
[INFO] | +- io.netty:netty-buffer:jar:4.0.27.Final:compile
[INFO] | +- io.netty:netty-transport:jar:4.0.27.Final:compile
[INFO] | +- io.reactivex:rxjava:jar:1.0.4:compile
[INFO] | +- io.netty:netty-common:jar:4.0.27.Final:compile
[INFO] | +- com.netflix.servo:servo-core:jar:0.7.5:compile
[INFO] | +- org.springframework.cloud:spring-cloud-consul-config:jar:1.0.0.M4:compile
[INFO] | \- org.springframework.cloud:spring-cloud-consul-discovery:jar:1.0.0.M4:compile
[INFO] | \- org.springframework.cloud:spring-cloud-consul-core:jar:1.0.0.M4:compile
[INFO] +- com.asadventure:wso2-filter:jar:abeq-SNAPSHOT:compile
[INFO] | \- org.springframework.ws:spring-ws-core:jar:2.2.3.RELEASE:compile
[INFO] | +- org.springframework.ws:spring-xml:jar:2.2.3.RELEASE:compile
[INFO] | \- org.springframework:spring-oxm:jar:4.1.6.RELEASE:compile
[INFO] +- com.vaadin:vaadin-server:jar:7.6.0:compile
[INFO] | +- com.vaadin:vaadin-sass-compiler:jar:0.9.13:compile
[INFO] | | +- org.w3c.css:sac:jar:1.3:compile
[INFO] | | +- com.vaadin.external.flute:flute:jar:1.3.0.gg2:compile
[INFO] | | \- com.yahoo.platform.yui:yuicompressor:jar:2.4.8:compile
[INFO] | | \- rhino:js:jar:1.7R2:compile
[INFO] | +- com.vaadin:vaadin-shared:jar:7.6.0:compile
[INFO] | | +- com.vaadin.external.streamhtmlparser:streamhtmlparser-jsilver:jar:0.0.10.vaadin1:compile
[INFO] | | \- com.vaadin.external.google:guava:jar:16.0.1.vaadin1:compile
[INFO] | \- org.jsoup:jsoup:jar:1.8.3:compile
[INFO] +- com.vaadin:vaadin-client-compiled:jar:7.6.0:compile
[INFO] +- com.vaadin:vaadin-spring-boot-starter:jar:1.0.0:compile
[INFO] | +- com.vaadin:vaadin-spring-boot:jar:1.0.0:compile
[INFO] | | \- com.vaadin:vaadin-spring:jar:1.0.0:compile
[INFO] | \- com.vaadin:vaadin-themes:jar:7.6.0:compile
[INFO] +- org.vaadin:viritin:jar:1.39:compile
[INFO] | +- org.vaadin.addon:confirmdialog:jar:2.1.3:compile
[INFO] | +- org.commonjava.googlecode.markdown4j:markdown4j:jar:2.2-cj-1.0:compile
[INFO] | +- commons-io:commons-io:jar:1.3.2:compile
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.9.2:compile
[INFO] | +- org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] | \- javax.el:javax.el-api:jar:2.2.4:compile
[INFO] +- com.vaadin:grid-renderers-collection-addon:jar:0.92:compile
[INFO] +- de.datenhahn.vaadin:componentrenderer:jar:0.1.1:compile
[INFO] | \- cglib:cglib:jar:3.2.0:compile
[INFO] | +- org.ow2.asm:asm:jar:5.0.3:compile
[INFO] | \- org.apache.ant:ant:jar:1.9.4:compile
[INFO] | \- org.apache.ant:ant-launcher:jar:1.9.4:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.3.0.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:1.3.0.RELEASE:compile
[INFO] | | \- org.aspectj:aspectjweaver:jar:1.8.7:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.3.0.RELEASE:compile
[INFO] | | +- org.apache.tomcat:tomcat-jdbc:jar:8.0.28:compile
[INFO] | | | \- org.apache.tomcat:tomcat-juli:jar:8.0.28:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:4.2.3.RELEASE:compile
[INFO] | +- org.hibernate:hibernate-entitymanager:jar:4.3.6.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile
[INFO] | | +- org.hibernate:hibernate-core:jar:4.3.6.Final:compile
[INFO] | | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | | \- org.jboss:jandex:jar:1.1.0.Final:compile
[INFO] | | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.5.Final:compile
[INFO] | | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] | | \- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] | +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:1.9.1.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-commons:jar:1.11.1.RELEASE:compile
[INFO] | | +- org.springframework:spring-orm:jar:4.2.3.RELEASE:compile
[INFO] | | \- org.springframework:spring-tx:jar:4.2.3.RELEASE:compile
[INFO] | \- org.springframework:spring-aspects:jar:4.1.6.RELEASE:compile
[INFO] +- com.microsoft.sqlserver:sqljdbc4:jar:3.0:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.springframework:spring-test:jar:4.1.6.RELEASE:test
[INFO] | \- org.springframework:spring-core:jar:4.2.3.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-web:jar:4.0.3.RELEASE:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework.security:spring-security-core:jar:4.0.3.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:4.1.6.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter:jar:1.3.0.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.3.0.RELEASE:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.16:compile
[INFO] \- org.springframework.boot:spring-boot-starter-log4j2:jar:1.2.3.RELEASE:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.13:compile
[INFO] +- org.slf4j:jul-to-slf4j:jar:1.7.13:compile
[INFO] +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.4.1:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.4.1:compile
[INFO] \- org.apache.logging.log4j:log4j-core:jar:2.4.1:compile
我们已经运行了一个Cassandra数据库,这将添加一个mssql数据库。一位同事指出它尝试使用Cassandra而不是mssql:
Caused by: java.lang.AbstractMethodError: org.springframework.data.repository.core.support.RepositoryFactorySupport.getTargetRepository(Lorg/springframework/data/repository/core/RepositoryInformation;)Ljava/lang/Object;
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:185) ~[spring-data-commons-1.11.1.RELEASE.jar:?]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:251) ~[spring-data-commons-1.11.1.RELEASE.jar:?]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:237) ~[spring-data-commons-1.11.1.RELEASE.jar:?]
at org.springframework.data.cassandra.repository.support.CassandraRepositoryFactoryBean.afterPropertiesSet(CassandraRepositoryFactoryBean.java:62) ~[spring-data-cassandra-1.1.2.RELEASE.jar:?]
答案 0 :(得分:0)
AbstractMethodError
都是非匹配依赖项的结果。当两个具有不兼容版本的库最终出现在类路径AbstractMethodError
上时。
在您的情况下,问题可能是由您指定的几个与持久性相关的依赖项引起的。默认情况下,使用时不应指定JPA / Hibernate依赖项:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
例如,如果您检查this tutorial,您将看到正在运行的应用程序的final pom仅包含驱动程序jar(h2),而不包括持久性的boot-starter依赖项。
答案 1 :(得分:0)
尝试从AfterSalesFileRepository中删除@Component。如果你有@ComponentScan启用,则spring boot会自动为扩展JpaRepository的任何接口创建存储库实现
答案 2 :(得分:0)
当您查看依赖树时,您将看到您正在混合Spring Boot 1.2.3和1.3.0中的Spring Boot jar版本。切勿混合版本。因此,您还混合了Spring 4.1.6和4.2.3的版本,这些版本总是很危险。
对于初学者,请删除spring-data-jpa
,hibernate
和spring-security
依赖项,并使用Spring Security for Spring(spring-boot-starter-security
),而不是手动添加依赖项。 (初学者带来适当的版本)。
同时删除spring-test
和junit
个依赖项,并将spring-boot-starter-test
与<scope>test</scope>
一起用作依赖项。
接下来有些东西正在为spring-boot-starter-log4j
提供弹簧启动1.2.3修复此问题,以便为启动版本使用正确的版本。
您还想再次使用cassandra使用启动器spring-boot-starter-data-cassandra
。
还有一个旧的spring-security-crypto
jar被拉入(3.2.7而不是4.0.3),这也会导致其他jar的旧依赖。
使用启动器可以避免指定版本(或者可以防止您添加错误的版本)。
<dependencies>
<!-- Vaadin -->
... Vaadin dependencies
<!-- hibernate dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
</dependency>
<!-- testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>