Olá pessoal,
. ____ _ __ _ _
/\ / ’ __ _ () __ __ _ \ \ \
( ( )__ | '_ | '| | ’ / ` | \ \ \
\/ )| |)| | | | | || (| | ) ) ) )
’ || .__|| ||| |_, | / / / /
=========||==============|/=////
:: Spring Boot :: (v2.1.8.RELEASE)
2019-09-30 18:01:49.516 INFO 2050 — [ restartedMain] com.doutores2019.DoutoresApplication : Starting DoutoresApplication on MacPro with PID 2050 (/Users/CristofeRocha/Documents/workspace-spring-tool-suite-4-4.4.0.RELEASE/Doutores/target/classes started by CristofeRocha in /Users/CristofeRocha/Documents/workspace-spring-tool-suite-4-4.4.0.RELEASE/Doutores)
2019-09-30 18:01:49.530 INFO 2050 — [ restartedMain] com.doutores2019.DoutoresApplication : No active profile set, falling back to default profiles: default
2019-09-30 18:01:49.671 INFO 2050 — [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set ‘spring.devtools.add-properties’ to ‘false’ to disable
2019-09-30 18:01:49.671 INFO 2050 — [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the ‘logging.level.web’ property to ‘DEBUG’
2019-09-30 18:01:51.138 INFO 2050 — [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2019-09-30 18:01:51.140 INFO 2050 — [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-09-30 18:01:51.246 INFO 2050 — [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 98ms. Found 1 repository interfaces.
2019-09-30 18:01:51.275 INFO 2050 — [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2019-09-30 18:01:51.287 INFO 2050 — [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-09-30 18:01:51.322 WARN 2050 — [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name ‘pessoaRepository’ defined in null: Cannot register bean definition [Root bean: class [org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean ‘pessoaRepository’: There is already [Root bean: class [org.springframework.data.jdbc.repository.support.JdbcRepositoryFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] bound.
2019-09-30 18:01:51.367 INFO 2050 — [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2019-09-30 18:01:51.373 ERROR 2050 — [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
The bean ‘pessoaRepository’, defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
A pessoa é:
package com.doutores2019.domain;
import javax.annotation.Generated;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@Entity
public class Pessoa {
@JsonInclude(Include.NON_NULL)
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@JsonInclude(Include.NON_NULL)
private int idade, cpf, identidade;
@JsonInclude(Include.NON_NULL)
private String nome, sexo;
public int getIdade() {
return idade;
}
public void setIdade(int idade) {
this.idade = idade;
}
public int getCpf() {
return cpf;
}
public void setCpf(int cpf) {
this.cpf = cpf;
}
public int getIdentidade() {
return identidade;
}
public void setIdentidade(int identidade) {
this.identidade = identidade;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getSexo() {
return sexo;
}
public void setSexo(String sexo) {
this.sexo = sexo;
}
}
Classe repository
package com.doutores2019.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import com.doutores2019.domain.Pessoa;
public interface PessoaRepository extends JpaRepository<Pessoa, Long>{
Pessoa findOne(Long id);
}