2017-12-15 13 views
1

오류의 원인과 해결 방법은 무엇입니까? git의 테스트 파일에서 찾을 수있는 다른 응용 프로그램으로이 시작 가능한 라이브러리를 시작합니다. 다음은 오류, pom.xml 및 프로젝트 소스를 볼 수 있습니다. 시작시SpringApplication 시작 실패 : 이름이 빈을 작성하는 중 오류가 발생했습니다.

오류

. ____   _   __ _ _ 
/\\/___'_ __ _ _(_)_ __ __ _ \ \ \ \ 
(()\___ | '_ | '_| | '_ \/ _` | \ \ \ \ 
\\/ ___)| |_)| | | | | || (_| | )))) 
    ' |____| .__|_| |_|_| |_\__, |//// 
=========|_|==============|___/=/_/_/_/ 
:: Spring Boot ::  (v1.5.9.RELEASE) 

[2017-12-16 00:25:38.056] - 18736 INFORMATION [main] --- ThePluginUsingTheLibrary: Starting ThePluginUsingTheLibrary on DESKTOP-E2R1T7J with PID 18736 (C:\Users\Robin\IdeaProjects\MyPvP\Core3.0\target\test-classes started by Robin in C:\Users\Robin\IdeaProjects\MyPvP\Core3.0) 
[2017-12-16 00:25:38.077] - 18736 INFORMATION [main] --- ThePluginUsingTheLibrary: No active profile set, falling back to default profiles: default 
[2017-12-16 00:25:38.164] - 18736 INFORMATION [main] --- org.springframework.context.annotation.AnnotationConfigApplicationContext: Refreshing org.spring[email protected]5427c60c: startup date [Sat Dec 16 00:25:38 CET 2017]; root of context hierarchy 
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
SLF4J: Defaulting to no-operation (NOP) logger implementation 
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 
[2017-12-16 00:25:39.032] - 18736 WARNUNG [main] --- org.springframework.context.annotation.AnnotationConfigApplicationContext: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userService' defined in file [C:\Users\Robin\IdeaProjects\MyPvP\Core3.0\target\classes\eu\mypvp\core\service\user\UserServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Initialization of bean failed; nested exception is java.lang.AbstractMethodError 
[2017-12-16 00:25:39.037] - 18736 INFORMATION [main] --- org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer: 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 
[2017-12-16 00:25:39.040] - 18736 SCHWERWIEGEND [main] --- org.springframework.boot.SpringApplication: Application startup failed 
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userService' defined in file [C:\Users\Robin\IdeaProjects\MyPvP\Core3.0\target\classes\eu\mypvp\core\service\user\UserServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Initialization of bean failed; nested exception is java.lang.AbstractMethodError 
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749) 
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) 
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) 
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) 
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) 
    at eu.mypvp.core.Core.init(Core.java:37) 
    at ThePluginUsingTheLibrary.main(ThePluginUsingTheLibrary.java:20) 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Initialization of bean failed; nested exception is java.lang.AbstractMethodError 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) 
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) 
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) 
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) 
    ... 18 more 
Caused by: java.lang.AbstractMethodError 
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:99) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:302) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:129) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1531) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) 
    ... 28 more 

의 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>eu.mypvp</groupId> 
    <artifactId>core</artifactId> 
    <version>3.0-SNAPSHOT</version> 

    <dependencyManagement> 
     <dependencies> 
      <dependency> 
       <groupId>org.springframework.data</groupId> 
       <artifactId>spring-data-releasetrain</artifactId> 
       <version>Kay-SR2</version> 
       <type>pom</type> 
       <scope>import</scope> 
      </dependency> 
     </dependencies> 
    </dependencyManagement> 
    <repositories> 
     <repository> 
      <id>spring-libs-release</id> 
      <name>Spring Releases</name> 
      <url>https://repo.spring.io/libs-release</url> 
      <snapshots> 
       <enabled>false</enabled> 
      </snapshots> 
     </repository> 
    </repositories> 

    <properties> 
     <!-- Generic properties --> 
     <jdk.version>1.8</jdk.version> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <skip.integration.tests>true</skip.integration.tests> 
     <skip.unit.tests>false</skip.unit.tests> 
    </properties> 

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

    <dependencies> 
     <!-- JUnit --> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
     </dependency> 

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

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-autoconfigure</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-orm</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-aspects</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context-support</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-tx</artifactId> 
     </dependency> 
     <!-- Spring-Data-JPA --> 
     <dependency> 
      <groupId>org.springframework.data</groupId> 
      <artifactId>spring-data-jpa</artifactId> 
     </dependency> 


     <!-- Apache --> 
     <dependency> 
      <groupId>commons-io</groupId> 
      <artifactId>commons-io</artifactId> 
      <version>2.5</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.commons</groupId> 
      <artifactId>commons-lang3</artifactId> 
      <version>3.7</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-logging</groupId> 
      <artifactId>commons-logging</artifactId> 
      <version>1.2</version> 
     </dependency> 


     <!-- Database --> 
     <dependency> 
      <groupId>com.datastax.cassandra</groupId> 
      <artifactId>cassandra-driver-core</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>redis.clients</groupId> 
      <artifactId>jedis</artifactId> 
     </dependency> 

     <!-- SQL querying (FluentJDBC) --> 
     <dependency> 
      <groupId>org.codejargon</groupId> 
      <artifactId>fluentjdbc</artifactId> 
      <version>1.8.3</version> 
     </dependency> 

     <!-- DataSource (HikariCP) --> 
     <dependency> 
      <groupId>com.zaxxer</groupId> 
      <artifactId>HikariCP</artifactId> 
     </dependency> 

     <!-- JPA Implementation (Hibernate) --> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-core</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-entitymanager</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-validator</artifactId> 
     </dependency> 

     <!-- Set of core libraries (Guava) --> 
     <dependency> 
      <groupId>com.google.guava</groupId> 
      <artifactId>guava</artifactId> 
      <version>23.0</version> 
     </dependency> 
     <!-- Json (Gson) --> 
     <dependency> 
      <groupId>com.google.code.gson</groupId> 
      <artifactId>gson</artifactId> 
     </dependency> 

     <!-- Cleaner code (Lombok) --> 
     <dependency> 
      <groupId>org.projectlombok</groupId> 
      <artifactId>lombok</artifactId> 
      <scope>provided</scope> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <!-- This plugin is needed to define the java version in maven project. --> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <configuration> 
        <source>${jdk.version}</source> 
        <target>${jdk.version}</target> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

의 치어 당신은 gitlab에이 프로젝트를 찾을 수 있습니다

출처 : UserRepository의도 구현이 스프링 데이터 JPA에 의해 이루어집니다 https://gitlab.com/roboflax/Spring-Data-In-Library

+0

1.X하는 봄 데이터를 다운 그레이드 부팅을 업그레이드합니다. (그리고 Spring Boot 부모 POM을 사용한다면 build 플러그인이 필요 없으며 이미 포함되어 있습니다.) – chrylis

+0

어떻게하면됩니까? @chrylis – RoboFlax

+0

'userRepository'에 대한 코드를 제공하십시오 –

답변

-1

, 그래서 당신은 단지에 UserRepository의 정의에 @Autowired를 넣어 가지고 UserServiceImpl

추천하고 또한

@Service("userService") 
@Transactional 
public class UserServiceImpl implements UserService { 

    @Autowired 
    private final UserRepository userRepository; 


    @Override 
    public Optional<User> getUserAccount(UUID uid) { 
     return this.userRepository.findOne(uid); 
    } 
} 

당신 돈 아래 @Service가 @Component의 특수화입니다.

+0

예외는'UserRepository'를 autowire하려고 시도하지만 그렇게하지 못한다고 말합니다. –

0

호환되지 않는 버전의 Spring Data and Boot를 사용하고 있습니다.

어느 2.x 또는 당신은 그것을 참조 년대`userRepository` 클래스를 포함 할 필요가