Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3637

A component required a bean named 'entityManagerFactory' that could not be found

$
0
0

I am doing a project in SpringBoot using Postgres and restful approach. My application is failing to start.I am new to this.Please help me with this problem.Below is my code:

Error

  .   ____          _            __ _ _ /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/  ___)| |_)| | | | | || (_| |  ) ) ) )'  |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot ::       (v2.4.2-SNAPSHOT)2020-12-30 21:42:08.397  INFO 7284 --- [  restartedMain] com.cg.pps.SpringRestApplication         : Starting SpringRestApplication using Java 15.0.1 on DESKTOP-7ODO40V with PID 7284 (D:\E drive\studymaterial\Sprint2\PersonalityPredictionSystemMus\target\classes started by BST in D:\E drive\studymaterial\Sprint2\PersonalityPredictionSystemMus)2020-12-30 21:42:08.410  INFO 7284 --- [  restartedMain] com.cg.pps.SpringRestApplication         : No active profile set, falling back to default profiles: default2020-12-30 21:42:08.677  INFO 7284 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable2020-12-30 21:42:08.678  INFO 7284 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'2020-12-30 21:42:10.722  INFO 7284 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.2020-12-30 21:42:10.921  INFO 7284 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 165 ms. Found 1 JPA repository interfaces.2020-12-30 21:42:12.831  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.hateoas.config.HateoasConfiguration' of type [org.springframework.hateoas.config.HateoasConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:12.848  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'relProviderPluginRegistry' of type [org.springframework.plugin.core.support.PluginRegistryFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:12.896  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'relProviderPluginRegistry' of type [org.springframework.plugin.core.OrderAwarePluginRegistry] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:12.907  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean '_relProvider' of type [org.springframework.hateoas.server.core.DelegatingLinkRelationProvider] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:12.933  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'messageResolver' of type [org.springframework.hateoas.mediatype.MessageSourceResolver] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:12.936  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.data.web.config.SpringDataJacksonConfiguration' of type [org.springframework.data.web.config.SpringDataJacksonConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:12.952  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonGeoModule' of type [org.springframework.data.geo.GeoModule] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.002  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration' of type [org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.011  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.018  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.097  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties' of type [org.springframework.boot.autoconfigure.jackson.JacksonProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.100  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'standardJacksonObjectMapperBuilderCustomizer' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration$StandardJackson2ObjectMapperBuilderCustomizer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.106  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$ParameterNamesModuleConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$ParameterNamesModuleConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.112  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'parameterNamesModule' of type [com.fasterxml.jackson.module.paramnames.ParameterNamesModule] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.114  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.137  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jsonComponentModule' of type [org.springframework.boot.jackson.JsonComponentModule] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.145  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonObjectMapperBuilder' of type [org.springframework.http.converter.json.Jackson2ObjectMapperBuilder] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.165  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'spring.data.rest-org.springframework.boot.autoconfigure.data.rest.RepositoryRestProperties' of type [org.springframework.boot.autoconfigure.data.rest.RepositoryRestProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.166  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'springBootRepositoryRestConfigurer' of type [org.springframework.boot.autoconfigure.data.rest.SpringBootRepositoryRestConfigurer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.169  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'configurerDelegate' of type [org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerDelegate] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.185  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration$StringHttpMessageConverterConfiguration' of type [org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration$StringHttpMessageConverterConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.204  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'stringHttpMessageConverter' of type [org.springframework.http.converter.StringHttpMessageConverter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.207  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.http.JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration' of type [org.springframework.boot.autoconfigure.http.JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.210  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.224  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonObjectMapperBuilder' of type [org.springframework.http.converter.json.Jackson2ObjectMapperBuilder] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.279  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonObjectMapper' of type [com.fasterxml.jackson.databind.ObjectMapper] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.284  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'mappingJackson2HttpMessageConverter' of type [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:13.286  INFO 7284 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration' of type [org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2020-12-30 21:42:14.804  INFO 7284 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8082 (http)2020-12-30 21:42:14.840  INFO 7284 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]2020-12-30 21:42:14.841  INFO 7284 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.41]2020-12-30 21:42:15.409  INFO 7284 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext2020-12-30 21:42:15.410  INFO 7284 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 6731 ms2020-12-30 21:42:16.076  WARN 7284 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cvRepo' defined in com.cg.pps.repository.CvRepo defined in @EnableJpaRepositories declared on SpringRestApplication: Cannot create inner bean '(inner bean)#2fe84e0e' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#2fe84e0e': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available2020-12-30 21:42:16.089  INFO 7284 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]2020-12-30 21:42:16.173  INFO 7284 --- [  restartedMain] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.2020-12-30 21:42:16.308 ERROR 7284 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : ***************************APPLICATION FAILED TO START***************************Description:A component required a bean named 'entityManagerFactory' that could not be found.Action:Consider defining a bean named 'entityManagerFactory' in your configuration.

App.java

    package com.cg.pps;    import org.springframework.boot.SpringApplication;    import org.springframework.boot.autoconfigure.EnableAutoConfiguration;    import org.springframework.boot.autoconfigure.SpringBootApplication;    import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;    import org.springframework.context.annotation.Bean;    import org.springframework.data.jpa.repository.config.EnableJpaRepositories;    import org.springframework.orm.hibernate5.LocalSessionFactoryBean;    @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})    @EnableJpaRepositories(basePackages = {"com.cg.pps.repository"})    @SpringBootApplication    public class SpringRestApplication {        public static void main(String[] args) {            SpringApplication.run(SpringRestApplication.class, args);        }    }

Controller

    package com.cg.pps.controller;    import java.util.List;    import com.cg.pps.model.*;    import com.cg.pps.service.*;    import org.springframework.beans.factory.annotation.Autowired;    import org.springframework.http.HttpStatus;    import org.springframework.http.ResponseEntity;    import org.springframework.web.bind.annotation.DeleteMapping;    import org.springframework.web.bind.annotation.GetMapping;    import org.springframework.web.bind.annotation.PathVariable;    import org.springframework.web.bind.annotation.PostMapping;    import org.springframework.web.bind.annotation.RequestBody;    import org.springframework.web.bind.annotation.RequestMapping;    import org.springframework.web.bind.annotation.RestController;    @RestController()    @RequestMapping("/candidatecv")    public class CandidateCvController {         @Autowired          private CandidateCvs candidatecvs;         @GetMapping("/getall")         public List<CandidateCv> getAllPeople() {             return candidatecvs.getAllCandiateCv();         }         @GetMapping("/get/{id}")         public CandidateCv getCandidateCvByEmail(@PathVariable String email) {             return candidatecvs.getCandidateCvByEmail(email);         }         @PostMapping("/create")         public String createCandidateCv(@PathVariable CandidateCv cv) {             if(cv != null) {                candidatecvs.createCandidateCv(cv);                 return "Cv Added";             } else {                 return "Request does not contain a body";             }         }    }

model

    package com.cg.pps.model;    import java.io.Serializable;    import javax.persistence.Column;    import javax.persistence.Entity;    import javax.persistence.Id;    import javax.persistence.Table;    //import the job package    @Entity    @Table(name="cand_info")    public class CandidateCv implements Serializable {        @Id        @Column(name="CandidateName", length=20)        private String CandidateName;           @Column(name="Email",length=12 ,unique=true)        private String email;        @Column(name="Phoneno",length=10)        private int phoneno;        @Column(name="Qualification",length=10)        private String qualification;        @Column(name="Experience",length=2)        private int exp;        @Column(name="Skill",length=10)        private String skill;        public CandidateCv() {            // TODO Auto-generated constructor stub        }        public CandidateCv(String candidateName, String email, int phoneno, String qualification, int exp, String skill) {            super();            CandidateName = candidateName;            this.email = email;            this.phoneno = phoneno;            this.qualification = qualification;            this.exp = exp;            this.skill = skill;        }        public String getCandidateName() {            return CandidateName;        }        public void setCandidateName(String candidateName) {            CandidateName = candidateName;        }        public String getEmail() {            return email;        }        public void setEmail(String email) {            this.email = email;        }        public int getPhoneno() {            return phoneno;        }        public void setPhoneno(int phoneno) {            this.phoneno = phoneno;        }        public String getQualification() {            return qualification;        }        public void setQualification(String qualification) {            this.qualification = qualification;        }        public int getExp() {            return exp;        }        public void setExp(int exp) {            this.exp = exp;        }        public String getSkill() {            return skill;        }        public void setSkill(String skill) {            this.skill = skill;        }    }

Repository

    package com.cg.pps.repository;    import com.cg.pps.model.CandidateCv;    import org.springframework.data.repository.CrudRepository;    import org.springframework.stereotype.Repository;    @Repository    public interface CvRepo extends CrudRepository<CandidateCv, Long> {        public boolean existByEmail(String email);        public CandidateCv findByEmail(String email);    }

ServiceInterface

    package com.cg.pps.service;    import com.cg.pps.model.*;    import java.util.List;    import org.springframework.stereotype.Service;    public interface CandidateCvs {        List<CandidateCv> getAllCandiateCv();        CandidateCv getCandidateCvByEmail(String email);        String createCandidateCv(CandidateCv e);    }**Service Implementation**    package com.cg.pps.service;    import java.util.List;    import javax.transaction.Transactional;    import org.springframework.beans.factory.annotation.Autowired;    import org.springframework.stereotype.Component;    import org.springframework.stereotype.Service;    import com.cg.pps.repository.CvRepo;    import com.cg.pps.model.CandidateCv;    @Transactional    @Service    public class CandidateCvImpl implements CandidateCvs {        private CvRepo repository;        @Override        public List<CandidateCv> getAllCandiateCv() {            return (List<CandidateCv>)repository.findAll();        }        @Override        public String createCandidateCv(CandidateCv e) {          String id=e.getEmail();            if(repository.existByEmail(id))         {                return "Candidate Cv already exists";                }        else {                repository.save(e);                return "Employee data successfully saved";            }        }        @Override        public CandidateCv getCandidateCvByEmail(String email) {            CandidateCv cv= new CandidateCv();              String id=cv.getEmail();                if(repository.existByEmail(id)) {                    return repository.findByEmail(email);                    }            else            {                return null;            }        }    }

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 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.4.1</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.example</groupId><artifactId>demo</artifactId><version>0.0.1-SNAPSHOT</version><name>demo</name><description>Demo project for Spring Boot</description><properties><java.version>1.8</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-jpa</artifactId></dependency><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-devtools</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

Please review my above codes and let me know what I am doing wrong.


Viewing all articles
Browse latest Browse all 3637

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>