Home > database >  UnsatisfiedDependencyException occur while executing spring-boot
UnsatisfiedDependencyException occur while executing spring-boot

Time:03-01

Can anyone kindly help me to rectify the error?It shows UnsatisfiedDependencyException occur while executing spring-boot and also beanException.

AdminRepo.java


    package com.adminplan.demo.repository;
    
    import org.springframework.data.jpa.repository.JpaRepository;
    import com.adminplan.demo.model.Admin;
    
    import java.util.Optional;
    
    public interface AdminRepo extends JpaRepository<Admin,Long> {
        void deleteAdminPlan(Long id);
    
        Optional<Admin> findAdminPlanById(Long id);
    }

AdminService.java


    package com.adminplan.demo.service;
    
    import com.adminplan.demo.exception.UserNotFoundException;
    import com.adminplan.demo.model.Admin;
    import com.adminplan.demo.repository.AdminRepo;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    
    import javax.transaction.Transactional;
    import java.util.List;
    
    @Service
    @Transactional
    public class AdminService {
        private final AdminRepo adminRepo;
    
        @Autowired
        public AdminService(AdminRepo adminRepo) {
            this.adminRepo = adminRepo;
        }
    
        public Admin addAdminPlan(Admin admin) {
            return adminRepo.save(admin);
        }
        public List<Admin> findAllAdminPlan() {return adminRepo.findAll(); }
    
        public Admin updateAdminPlan(Admin adminplan){ return adminRepo.save(adminplan); }
    
        public Admin findAdminPlanById(Long id){
            return adminRepo.findAdminPlanById(id)
                    .orElseThrow(()-> new UserNotFoundException("User by id " id " was not found"));
        }
    
        public void deleteAdminPlan(Long id){ adminRepo.deleteAdminPlan(id);}
    }

AdminController.java


    package com.adminplan.demo.controller;
    
    import com.adminplan.demo.model.Admin;
    import com.adminplan.demo.service.AdminService;
    import org.springframework.http.HttpStatus;
    import org.springframework.http.ResponseEntity;
    import org.springframework.web.bind.annotation.*;
    
    import java.util.List;
    
    @RestController
    @RequestMapping("/admin-plan")
    public class AdminController {
        private final AdminService adminService;
    
        public AdminController(AdminService adminService) {
            this.adminService = adminService;
        }
    
        @GetMapping("/all")
        public ResponseEntity<List<Admin>> getAllAdminPlan(){
            List<Admin> adminPlans= adminService.findAllAdminPlan();
            return new ResponseEntity<>(adminPlans, HttpStatus.OK);
        }
    
        @GetMapping("/find/{id}")
        public ResponseEntity<Admin> getAdminPlanById(@PathVariable("id") Long id){
            Admin adminPlan= adminService.findAdminPlanById(id);
            return new ResponseEntity<>(adminPlan, HttpStatus.OK);
        }
    
        @PostMapping("/add-plan")
        public ResponseEntity<Admin> addAdminPlan(@RequestBody Admin admin){
            Admin newAdminPlan = adminService.addAdminPlan(admin);
            return new ResponseEntity<>(newAdminPlan, HttpStatus.CREATED);
        }
    
        @PutMapping("/update")
        public ResponseEntity<Admin> updateAdminPlan(@RequestBody Admin admin){
            Admin updatePlan = adminService.updateAdminPlan(admin);
            return new ResponseEntity<>(updatePlan, HttpStatus.OK);
        }
    
        @DeleteMapping("/delete/{id}")
        public ResponseEntity<?> deleteAdminPlan(@PathVariable("id") Long id){
            adminService.deleteAdminPlan(id);
            return new ResponseEntity<>(HttpStatus.OK);
        }
    
    
    
    }

application.properties


    # MySQL Configuration
    spring.datasource.url=jdbc:mysql://localhost:3307/adminplan
    spring.datasource.username=****
    spring.datasource.password=****
    spring.jpa.show-sql=true
    spring.jpa.hibernate.ddl-auto=update
    spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect

Error

 

    :: Spring Boot ::                (v2.6.4)
    
    2022-02-28 14:31:57.433  INFO 1956 --- [           main] com.adminplan.demo.DemoApplication       : Starting DemoApplication using Java 11.0.13 on DESKTOP-MQ2O3FR with PID 1956 (D:\spring boot\admin\target\classes started by keerthi in D:\spring boot\admin)
    2022-02-28 14:31:57.433  INFO 1956 --- [           main] com.adminplan.demo.DemoApplication       : No active profile set, falling back to 1 default profile: "default"
    2022-02-28 14:31:58.247  INFO 1956 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
    2022-02-28 14:31:58.294  INFO 1956 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 42 ms. Found 1 JPA repository interfaces.
    2022-02-28 14:31:59.487  INFO 1956 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
    2022-02-28 14:31:59.487  INFO 1956 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
    2022-02-28 14:31:59.487  INFO 1956 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.58]
    2022-02-28 14:31:59.596  INFO 1956 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
    2022-02-28 14:31:59.596  INFO 1956 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2101 ms
    2022-02-28 14:31:59.831  INFO 1956 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
    2022-02-28 14:31:59.877  INFO 1956 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.6.5.Final
    2022-02-28 14:32:00.018  INFO 1956 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
    2022-02-28 14:32:00.112  INFO 1956 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
    2022-02-28 14:32:00.424  INFO 1956 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
    2022-02-28 14:32:00.440  INFO 1956 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
    2022-02-28 14:32:01.065  INFO 1956 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
    2022-02-28 14:32:01.080  INFO 1956 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
    2022-02-28 14:32:01.440  WARN 1956 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'adminController' defined in file [D:\spring boot\admin\target\classes\com\adminplan\demo\controller\AdminController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'adminService' defined in file [D:\spring boot\admin\target\classes\com\adminplan\demo\service\AdminService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminRepo' defined in com.adminplan.demo.repository.AdminRepo defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! Reason: Failed to create query for method public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! No property 'deleteAdminPlan' found for type 'Admin'!; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! No property 'deleteAdminPlan' found for type 'Admin'!
    2022-02-28 14:32:01.440  INFO 1956 --- [           main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
    2022-02-28 14:32:01.440  INFO 1956 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
    2022-02-28 14:32:01.455  INFO 1956 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
    2022-02-28 14:32:01.455  INFO 1956 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
    2022-02-28 14:32:01.471  INFO 1956 --- [           main] ConditionEvaluationReportLoggingListener : 
    
    Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
    2022-02-28 14:32:01.486 ERROR 1956 --- [           main] o.s.boot.SpringApplication               : Application run failed
    
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'adminController' defined in file [D:\spring boot\admin\target\classes\com\adminplan\demo\controller\AdminController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'adminService' defined in file [D:\spring boot\admin\target\classes\com\adminplan\demo\service\AdminService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminRepo' defined in com.adminplan.demo.repository.AdminRepo defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! Reason: Failed to create query for method public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! No property 'deleteAdminPlan' found for type 'Admin'!; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! No property 'deleteAdminPlan' found for type 'Admin'!
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.16.jar:5.3.16]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.16.jar:5.3.16]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.4.jar:2.6.4]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) ~[spring-boot-2.6.4.jar:2.6.4]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) ~[spring-boot-2.6.4.jar:2.6.4]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-2.6.4.jar:2.6.4]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) ~[spring-boot-2.6.4.jar:2.6.4]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.4.jar:2.6.4]
        at com.adminplan.demo.DemoApplication.main(DemoApplication.java:11) ~[classes/:na]
    Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'adminService' defined in file [D:\spring boot\admin\target\classes\com\adminplan\demo\service\AdminService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminRepo' defined in com.adminplan.demo.repository.AdminRepo defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! Reason: Failed to create query for method public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! No property 'deleteAdminPlan' found for type 'Admin'!; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! No property 'deleteAdminPlan' found for type 'Admin'!
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.16.jar:5.3.16]
        ... 19 common frames omitted
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminRepo' defined in com.adminplan.demo.repository.AdminRepo defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! Reason: Failed to create query for method public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! No property 'deleteAdminPlan' found for type 'Admin'!; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! No property 'deleteAdminPlan' found for type 'Admin'!
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.16.jar:5.3.16]
        ... 33 common frames omitted
    Caused by: org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! Reason: Failed to create query for method public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! No property 'deleteAdminPlan' found for type 'Admin'!; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! No property 'deleteAdminPlan' found for type 'Admin'!
        at org.springframework.data.repository.query.QueryCreationException.create(QueryCreationException.java:101) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:106) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lambda$mapMethodsToQuery$1(QueryExecutorMethodInterceptor.java:94) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[na:na]
        at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) ~[na:na]
        at java.base/java.util.Collections$UnmodifiableCollection$1.forEachRemaining(Collections.java:1054) ~[na:na]
        at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
        at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.mapMethodsToQuery(QueryExecutorMethodInterceptor.java:96) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lambda$new$0(QueryExecutorMethodInterceptor.java:86) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at java.base/java.util.Optional.map(Optional.java:265) ~[na:na]
        at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.<init>(QueryExecutorMethodInterceptor.java:86) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:364) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:322) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.util.Lazy.getNullable(Lazy.java:230) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.util.Lazy.get(Lazy.java:114) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:328) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:144) ~[spring-data-jpa-2.6.2.jar:2.6.2]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.16.jar:5.3.16]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.16.jar:5.3.16]
        ... 44 common frames omitted
    Caused by: java.lang.IllegalArgumentException: Failed to create query for method public abstract void com.adminplan.demo.repository.AdminRepo.deleteAdminPlan(java.lang.Long)! No property 'deleteAdminPlan' found for type 'Admin'!
        at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:96) ~[spring-data-jpa-2.6.2.jar:2.6.2]
        at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:113) ~[spring-data-jpa-2.6.2.jar:2.6.2]
        at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:254) ~[spring-data-jpa-2.6.2.jar:2.6.2]
        at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:87) ~[spring-data-jpa-2.6.2.jar:2.6.2]
        at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:102) ~[spring-data-commons-2.6.2.jar:2.6.2]
        ... 66 common frames omitted
    Caused by: org.springframework.data.mapping.PropertyReferenceException: No property 'deleteAdminPlan' found for type 'Admin'!
        at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:90) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:437) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:413) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:366) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at java.base/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330) ~[na:na]
        at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:348) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:331) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.repository.query.parser.Part.<init>(Part.java:81) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.repository.query.parser.PartTree$OrPart.lambda$new$0(PartTree.java:249) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[na:na]
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) ~[na:na]
        at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
        at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:250) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.repository.query.parser.PartTree$Predicate.lambda$new$0(PartTree.java:383) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[na:na]
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) ~[na:na]
        at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
        at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:384) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:92) ~[spring-data-commons-2.6.2.jar:2.6.2]
        at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:89) ~[spring-data-jpa-2.6.2.jar:2.6.2]
        ... 70 common frames omitted
    
    
    Process finished with exit code 1

Please go through the Above code and help me to correct it.It shows UnsatisfiedDependencyException occur while executing spring-boot and also beanException.

CodePudding user response:

Since your AdminRepo extends JpaRepository - which is a descendant of CrudRepository

these methods are already available to AdminRepo

try removing this method deleteAdminPlan and changing AdminController to call the provided deleteById method


In order to generate the implementation for the Repository methods, spring parses the Repository method names into multiple parts. see these sections for more detail:

https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.query-methods.query-creation)

https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.query-methods.query-creation

  • Related