Home Parameter 0 of method standardParameterResolver ... required a single bean, but 2 were found
Reply: 1

Parameter 0 of method standardParameterResolver ... required a single bean, but 2 were found

Volodymyr Voleniuk
1#
Volodymyr Voleniuk Published in 2017-12-06 15:10:47Z

I have the problem, which I cannot by myself, because of totally zero experience in Spring Boot.

When I'm trying to run my SpringApplication, I am getting this log:


"C:\Program Files\Java\jdk1.8.0_111\bin\java" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=54556 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.2.6\lib\idea_rt.jar=54557:C:\Program Files\JetBrains\IntelliJ IDEA 2017.2.6\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_111\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\rt.jar;C:\Users\Volodymyr\IdeaProjects\pgs\target\classes;C:\Users\Volodymyr.m2\repository\org\springframework\boot\spring-boot-starter-cache\1.5.9.RELEASE\spring-boot-starter-cache-1.5.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\boot\spring-boot-starter\1.5.9.RELEASE\spring-boot-starter-1.5.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\boot\spring-boot\1.5.9.RELEASE\spring-boot-1.5.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\boot\spring-boot-autoconfigure\1.5.9.RELEASE\spring-boot-autoconfigure-1.5.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\boot\spring-boot-starter-logging\1.5.9.RELEASE\spring-boot-starter-logging-1.5.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\ch\qos\logback\logback-classic\1.1.11\logback-classic-1.1.11.jar;C:\Users\Volodymyr.m2\repository\ch\qos\logback\logback-core\1.1.11\logback-core-1.1.11.jar;C:\Users\Volodymyr.m2\repository\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;C:\Users\Volodymyr.m2\repository\org\slf4j\log4j-over-slf4j\1.7.25\log4j-over-slf4j-1.7.25.jar;C:\Users\Volodymyr.m2\repository\org\yaml\snakeyaml\1.17\snakeyaml-1.17.jar;C:\Users\Volodymyr.m2\repository\org\springframework\spring-context\4.3.13.RELEASE\spring-context-4.3.13.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\spring-beans\4.3.13.RELEASE\spring-beans-4.3.13.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\spring-expression\4.3.13.RELEASE\spring-expression-4.3.13.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\spring-context-support\4.3.13.RELEASE\spring-context-support-4.3.13.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\boot\spring-boot-starter-data-jpa\1.5.9.RELEASE\spring-boot-starter-data-jpa-1.5.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\boot\spring-boot-starter-aop\1.5.9.RELEASE\spring-boot-starter-aop-1.5.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\aspectj\aspectjweaver\1.8.13\aspectjweaver-1.8.13.jar;C:\Users\Volodymyr.m2\repository\org\hibernate\hibernate-core\5.0.12.Final\hibernate-core-5.0.12.Final.jar;C:\Users\Volodymyr.m2\repository\org\jboss\logging\jboss-logging\3.3.1.Final\jboss-logging-3.3.1.Final.jar;C:\Users\Volodymyr.m2\repository\org\hibernate\javax\persistence\hibernate-jpa-2.1-api\1.0.0.Final\hibernate-jpa-2.1-api-1.0.0.Final.jar;C:\Users\Volodymyr.m2\repository\org\javassist\javassist\3.21.0-GA\javassist-3.21.0-GA.jar;C:\Users\Volodymyr.m2\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;C:\Users\Volodymyr.m2\repository\org\jboss\jandex\2.0.0.Final\jandex-2.0.0.Final.jar;C:\Users\Volodymyr.m2\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;C:\Users\Volodymyr.m2\repository\org\hibernate\common\hibernate-commons-annotations\5.0.1.Final\hibernate-commons-annotations-5.0.1.Final.jar;C:\Users\Volodymyr.m2\repository\org\hibernate\hibernate-entitymanager\5.0.12.Final\hibernate-entitymanager-5.0.12.Final.jar;C:\Users\Volodymyr.m2\repository\javax\transaction\javax.transaction-api\1.2\javax.transaction-api-1.2.jar;C:\Users\Volodymyr.m2\repository\org\springframework\data\spring-data-jpa\1.11.9.RELEASE\spring-data-jpa-1.11.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\data\spring-data-commons\1.13.9.RELEASE\spring-data-commons-1.13.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\spring-orm\4.3.13.RELEASE\spring-orm-4.3.13.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\spring-tx\4.3.13.RELEASE\spring-tx-4.3.13.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;C:\Users\Volodymyr.m2\repository\org\slf4j\jcl-over-slf4j\1.7.25\jcl-over-slf4j-1.7.25.jar;C:\Users\Volodymyr.m2\repository\org\springframework\spring-aspects\4.3.13.RELEASE\spring-aspects-4.3.13.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\boot\spring-boot-starter-data-rest\1.5.9.RELEASE\spring-boot-starter-data-rest-1.5.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.8.0\jackson-annotations-2.8.0.jar;C:\Users\Volodymyr.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.8.10\jackson-databind-2.8.10.jar;C:\Users\Volodymyr.m2\repository\com\fasterxml\jackson\core\jackson-core\2.8.10\jackson-core-2.8.10.jar;C:\Users\Volodymyr.m2\repository\org\springframework\data\spring-data-rest-webmvc\2.6.9.RELEASE\spring-data-rest-webmvc-2.6.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\data\spring-data-rest-core\2.6.9.RELEASE\spring-data-rest-core-2.6.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\atteo\evo-inflector\1.2.2\evo-inflector-1.2.2.jar;C:\Users\Volodymyr.m2\repository\org\springframework\boot\spring-boot-starter-hateoas\1.5.9.RELEASE\spring-boot-starter-hateoas-1.5.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\hateoas\spring-hateoas\0.23.0.RELEASE\spring-hateoas-0.23.0.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\plugin\spring-plugin-core\1.2.0.RELEASE\spring-plugin-core-1.2.0.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\1.5.9.RELEASE\spring-boot-starter-jdbc-1.5.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\apache\tomcat\tomcat-jdbc\8.5.23\tomcat-jdbc-8.5.23.jar;C:\Users\Volodymyr.m2\repository\org\apache\tomcat\tomcat-juli\8.5.23\tomcat-juli-8.5.23.jar;C:\Users\Volodymyr.m2\repository\org\springframework\spring-jdbc\4.3.13.RELEASE\spring-jdbc-4.3.13.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\boot\spring-boot-starter-security\1.5.9.RELEASE\spring-boot-starter-security-1.5.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\spring-aop\4.3.13.RELEASE\spring-aop-4.3.13.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\security\spring-security-config\4.2.3.RELEASE\spring-security-config-4.2.3.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\security\spring-security-web\4.2.3.RELEASE\spring-security-web-4.2.3.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\session\spring-session\1.3.1.RELEASE\spring-session-1.3.1.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\shell\spring-shell-starter\2.0.0.M2\spring-shell-starter-2.0.0.M2.jar;C:\Users\Volodymyr.m2\repository\org\springframework\shell\spring-shell-core\2.0.0.M2\spring-shell-core-2.0.0.M2.jar;C:\Users\Volodymyr.m2\repository\org\jline\jline\3.4.0\jline-3.4.0.jar;C:\Users\Volodymyr.m2\repository\org\jline\jline-terminal-jna\3.4.0\jline-terminal-jna-3.4.0.jar;C:\Users\Volodymyr.m2\repository\net\java\dev\jna\jna\4.2.2\jna-4.2.2.jar;C:\Users\Volodymyr.m2\repository\org\jline\jline-terminal\3.4.0\jline-terminal-3.4.0.jar;C:\Users\Volodymyr.m2\repository\org\springframework\shell\spring-shell-standard\2.0.0.M2\spring-shell-standard-2.0.0.M2.jar;C:\Users\Volodymyr.m2\repository\org\springframework\shell\spring-shell-standard-commands\2.0.0.M2\spring-shell-standard-commands-2.0.0.M2.jar;C:\Users\Volodymyr.m2\repository\org\springframework\shell\spring-shell-shell1-adapter\2.0.0.M2\spring-shell-shell1-adapter-2.0.0.M2.jar;C:\Users\Volodymyr.m2\repository\org\springframework\shell\spring-shell-jcommander-adapter\2.0.0.M2\spring-shell-jcommander-adapter-2.0.0.M2.jar;C:\Users\Volodymyr.m2\repository\org\springframework\shell\spring-shell-table\2.0.0.M2\spring-shell-table-2.0.0.M2.jar;C:\Users\Volodymyr.m2\repository\org\springframework\boot\spring-boot-starter-validation\1.5.9.RELEASE\spring-boot-starter-validation-1.5.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\8.5.23\tomcat-embed-el-8.5.23.jar;C:\Users\Volodymyr.m2\repository\org\hibernate\hibernate-validator\5.3.6.Final\hibernate-validator-5.3.6.Final.jar;C:\Users\Volodymyr.m2\repository\javax\validation\validation-api\1.1.0.Final\validation-api-1.1.0.Final.jar;C:\Users\Volodymyr.m2\repository\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;C:\Users\Volodymyr.m2\repository\org\springframework\boot\spring-boot-starter-web\1.5.9.RELEASE\spring-boot-starter-web-1.5.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\1.5.9.RELEASE\spring-boot-starter-tomcat-1.5.9.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\8.5.23\tomcat-embed-core-8.5.23.jar;C:\Users\Volodymyr.m2\repository\org\apache\tomcat\tomcat-annotations-api\8.5.23\tomcat-annotations-api-8.5.23.jar;C:\Users\Volodymyr.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.23\tomcat-embed-websocket-8.5.23.jar;C:\Users\Volodymyr.m2\repository\org\springframework\spring-web\4.3.13.RELEASE\spring-web-4.3.13.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\spring-webmvc\4.3.13.RELEASE\spring-webmvc-4.3.13.RELEASE.jar;C:\Users\Volodymyr.m2\repository\com\h2database\h2\1.4.196\h2-1.4.196.jar;C:\Users\Volodymyr.m2\repository\org\springframework\spring-core\4.3.13.RELEASE\spring-core-4.3.13.RELEASE.jar;C:\Users\Volodymyr.m2\repository\org\springframework\security\spring-security-core\4.2.3.RELEASE\spring-security-core-4.2.3.RELEASE.jar;C:\Users\Volodymyr.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar" com.hypeofpipe.pgs.PgsApplication

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

2017-12-06 16:01:34.437 INFO 6960 --- [ main] com.hypeofpipe.pgs.PgsApplication : Starting PgsApplication on LAPTOP-LSF16BAT with PID 6960 (C:\Users\Volodymyr\IdeaProjects\pgs\target\classes started by Volodymyr in C:\Users\Volodymyr\IdeaProjects\pgs) 2017-12-06 16:01:34.442 INFO 6960 --- [ main] com.hypeofpipe.pgs.PgsApplication : No active profile set, falling back to default profiles: default 2017-12-06 16:01:34.557 INFO 6960 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@525f1e4e: startup date [Wed Dec 06 16:01:34 CET 2017]; root of context hierarchy 2017-12-06 16:01:35.971 INFO 6960 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'httpRequestHandlerAdapter' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration; factoryMethodName=httpRequestHandlerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; factoryMethodName=httpRequestHandlerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]] 2017-12-06 16:01:36.847 INFO 6960 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$572a4fb0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2017-12-06 16:01:37.441 INFO 6960 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 2017-12-06 16:01:37.453 INFO 6960 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2017-12-06 16:01:37.456 INFO 6960 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.23 2017-12-06 16:01:37.593 INFO 6960 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2017-12-06 16:01:37.594 INFO 6960 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3043 ms 2017-12-06 16:01:37.866 INFO 6960 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/] 2017-12-06 16:01:37.867 INFO 6960 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/] 2017-12-06 16:01:37.867 INFO 6960 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/] 2017-12-06 16:01:37.867 INFO 6960 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/] 2017-12-06 16:01:37.869 INFO 6960 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*] 2017-12-06 16:01:37.869 INFO 6960 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2017-12-06 16:01:38.448 INFO 6960 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2017-12-06 16:01:38.463 INFO 6960 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2017-12-06 16:01:38.612 INFO 6960 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final} 2017-12-06 16:01:38.614 INFO 6960 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2017-12-06 16:01:38.616 INFO 6960 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist 2017-12-06 16:01:38.691 INFO 6960 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 2017-12-06 16:01:38.885 INFO 6960 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect 2017-12-06 16:01:39.722 INFO 6960 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export 2017-12-06 16:01:39.794 INFO 6960 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete 2017-12-06 16:01:39.848 INFO 6960 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2017-12-06 16:01:41.016 WARN 6960 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'parameterValidationExceptionResultHandler': Unsatisfied dependency expressed through field 'parameterResolvers'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'standardParameterResolver' defined in class path resource [org/springframework/shell/standard/StandardAPIAutoConfiguration.class]: Unsatisfied dependency expressed through method 'standardParameterResolver' parameter 0; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.core.convert.ConversionService' available: expected single matching bean but found 2: mvcConversionService,defaultConversionService 2017-12-06 16:01:41.018 INFO 6960 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' 2017-12-06 16:01:41.019 INFO 6960 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export 2017-12-06 16:01:41.041 INFO 6960 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete 2017-12-06 16:01:41.044 INFO 6960 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2017-12-06 16:01:41.066 INFO 6960 --- [ main] utoConfigurationReportLoggingInitializer :

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2017-12-06 16:01:41.074 ERROR 6960 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

Parameter 0 of method standardParameterResolver in org.springframework.shell.standard.StandardAPIAutoConfiguration required a single bean, but 2 were found: - mvcConversionService: defined by method 'mvcConversionService' in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class] - defaultConversionService: defined by method 'defaultConversionService' in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]

Action:

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

Process finished with exit code 1

So, I've tried to disable JMX agent and to add @Primary annotation about my bean. Doesn't work though.

Here's my source code:

pgs_controllers_SubjectsRestController.java

package com.hypeofpipe.pgs.controllers;

//I've reduced import to fit this post into 30k characters

@RestController
@RequestMapping("/{email}/subjects")
public class SubjectsRestController {

    private final PresenceRepository presenceRepository;

    private final StudentRepository studentRepository;

    private final SubjectRepository subjectRepository;

    private final TeacherRepository teacherRepository;

    @Autowired
    SubjectsRestController(PresenceRepository presenceRepository,
                           StudentRepository studentRepository,
                           SubjectRepository subjectRepository,
                           TeacherRepository teacherRepository){
        this.presenceRepository = presenceRepository;
        this.studentRepository = studentRepository;
        this.subjectRepository = subjectRepository;
        this.teacherRepository = teacherRepository;
    }

    @RequestMapping(method = RequestMethod.GET)
    Collection<Subject> readSubjects(@PathVariable String email){
        if (this.validateUser(email)){ //check it is student
            return this.subjectRepository.findByStudentEmail(email);
        }
        else {
            return this.subjectRepository.findByTeacherEmail(email);
        }
    }

    private boolean validateUser(String userId) {
        char c = userId.charAt(0);
        boolean retBol = false;
        if (Character.getType(c) == Character.getType('s')) {
            retBol = true;
        } else if (Character.getType(c) == Character.getType('t')) {
            retBol = false;
        }

        return retBol;
    }

}

pgs_entities_Student.java

package com.hypeofpipe.pgs.entities;

//I've reduced import to fit this post into 30k characters

@Entity
public class Student {

    @OneToMany(mappedBy = "student")
    public Set<Presence> presences =
            new HashSet<>();

    @Id
    @GeneratedValue
    private Long id;

    @OneToMany
    public Set<Subject> subjects =
            new HashSet<>();

    public Set<Subject> getSubjects() {
        return subjects;
    }

    public Set<Presence> getPresences() {
        return presences;
    }

    public Long getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getSurname() {
        return surname;
    }

    public String getEmail() {
        return email;
    }

    @JsonIgnore
    private String name;
    private String surname;
    private String email;
    private String password;

    public Student(String name, String surname, String email, String password) {
        this.name = name;
        this.surname = surname;
        this.email = email;
        this.password = password;
    }

    Student(){

    }

}

pgs_entities_Subject.java

package com.hypeofpipe.pgs.entities;

import com.fasterxml.jackson.annotation.JsonIgnore;

//I've reduced import to fit this post into 30k characters

@Entity
public class Subject {

    @Id
    @GeneratedValue
    private Long id;

    @OneToMany
    public Set<Presence> presences =
            new HashSet<>();

    @ManyToOne
    private Teacher teacher;

    @ManyToOne
    private Student student;

    public Long getId() {
        return id;
    }

    public Set<Presence> getPresences() {
        return presences;
    }

    public Teacher getTeacher() {
        return teacher;
    }

    public String getName() {
        return name;
    }

    @JsonIgnore
    private String name;

    public Subject(String name,
                   Teacher teacher,
                   Student student){
        this.name = name;
        this.teacher = teacher;
        this.student = student;
    }

    Subject(){

    }

}

pgs_entities_Teacher.java

package com.hypeofpipe.pgs.entities;

//I've reduced import to fit this post into 30k characters

@Entity
public class Teacher {

    @Id

    @GeneratedValue
    private Long id;

    @OneToMany
    public Set<Subject> subjects =
            new HashSet<>();

    public Long getId() {
        return id;
    }

    public Set<Subject> getSubjects() {
        return subjects;
    }

    public String getName() {
        return name;
    }

    public String getSurname() {
        return surname;
    }

    public String getEmail() {
        return email;
    }

    public String getPassword() {
        return password;
    }

    @JsonIgnore
    private String name;
    private String surname;
    private String email;
    private String password;

    public Teacher(String name, String surname, String email, String password) {
        this.name = name;
        this.surname = surname;
        this.email = email;
        this.password = password;
    }

    Teacher(){

    }

}

pgs_PgsApplication.java

package com.hypeofpipe.pgs;

//I've reduced import to fit this post into 30k characters

import java.util.Arrays;
import java.util.Random;

@SpringBootApplication
public class PgsApplication {

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

    @Bean
    @Primary
    CommandLineRunner init(StudentRepository studentRepository,
                           PresenceRepository presenceRepository,
                           SubjectRepository subjectRepository,
                           TeacherRepository teacherRepository) {
        return (evt) -> Arrays.asList(
                "sadampol@gmail.com,sromapor@gmail.com,tbazilev@gmail.com".split(","))
                .forEach(
                        a -> {
                            Student student;
                                student = studentRepository.save(
                                        new Student(
                                                "" + a.substring(0, 2),
                                                "" + a.substring(2, 4),
                                                a,
                                                "password"
                                        )
                                );
                            Teacher teacher =
                                    teacherRepository.save(new Teacher(
                                            "Ba" + a.substring(0, 2),
                                            "Da" + a.substring(2, 4),
                                            a,
                                            "password"
                                    ));
                            Subject subject =
                                    subjectRepository.save(
                                            new Subject(
                                                    "Test" + Math.random(),
                                                    teacher,
                                                    student
                                            )
                                    );
                            Presence presence =
                                    presenceRepository.save(
                                            new Presence(
                                                    student,
                                                    subject,
                                                    new Random().nextBoolean()
                                            )
                                    );
                        });
    }
}

pgs_repositories_PresenceRepository.java

package com.hypeofpipe.pgs.repositories;

//I've reduced import to fit this post into 30k characters

public interface PresenceRepository extends JpaRepository<Presence, Long> {
    Collection<Presence> findByStudentEmail(String email);
}

pgs_repositories_StudentRepository.java

package com.hypeofpipe.pgs.repositories;

//I've reduced import to fit this post into 30k characters

public interface StudentRepository extends JpaRepository<Student, Long> {
    Collection<Student> findByEmail(String email);
    Collection<Student> findByNameAndSurname(String name, String surname);
}

pgs_repositories_SubjectRepository.java

package com.hypeofpipe.pgs.repositories;

//I've reduced import to fit this post into 30k characters

public interface SubjectRepository extends JpaRepository<Subject, Long> {
    Collection<Subject> findByTeacherEmail(String email);
    Collection<Subject> findByStudentEmail(String email);
}

pgs_repositories_TeacherRepository.java

package com.hypeofpipe.pgs.repositories;

//I've reduced import to fit this post into 30k characters

public interface TeacherRepository extends JpaRepository<Teacher, Long> {

    Optional<Teacher> findByEmail(String email);

}

I would appreciate any help.

Volodymyr Voleniuk
2#
Volodymyr Voleniuk Reply to 2017-12-06 22:00:45Z

I just recreated project in Spring Initialazer and everything is working. Nice.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.336299 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO