Skip to main content
se eliminaron 63 caracteres en el cuerpo
Origen Enlace
Benito-B
  • 4.2k
  • 3
  • 14
  • 28
``` package com.alkemyApi.app.entity;
    
    import java.util.List;
    
    import javax.persistence.Basic;
    import javax.persistence.CascadeType;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.JoinTable;
    import javax.persistence.ManyToMany;
    import javax.persistence.Table;
    
    import com.fasterxml.jackson.annotation.JsonManagedReference;
    
    @Entity
    @Table(name="characters")
    public class Character {
    
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        private long id_character;
        
        @Basic
        private int age;
        private String image;
        private String history;
        private double weight;
        
        @JsonManagedReference
        @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
        @JoinTable(name="characters_shooting",
        joinColumns = {@JoinColumn(name="id_character", nullable=false)},
        inverseJoinColumns= {@JoinColumn(name="id_shooting", nullable=false)})
        private List<Shooting> shootingList;
    
        public Character(long id_character, int age, String image, String history, double weight,
                List<Shooting> shootingList) {
            super();
            this.id_character = id_character;
            this.age = age;
            this.image = image;
            this.history = history;
            this.weight = weight;
            this.shootingList = shootingList;
        } 
 
Servicios;
Interfaz
```package

Servicios; Interfaz

package com.alkemyApi.app.service;
    
    import java.util.List;
    
    public interface ICharacterService {
    
        public void saveCharacters(Character character);
        public void deleteCharacters(Character character);
        public List<Character> findAllCharacters();
        public Character findCharactersById(long id);
}
 ```

clase:   }
```package

Clase:

package com.alkemyApi.app.service;
    
    import java.util.List;
    import java.util.Optional;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    
    import com.alkemyApi.app.repository.ICharacter;
    @Service
    public class CharacterService implements ICharacterService {
    
        @Autowired
        private ICharacter characRep;
        
        @Override
        public void saveCharacters(Character character) {
            characRep.save(character);
        }
    
        @Override
        public void deleteCharacters(Character character) {
            characRep.delete(character);
        }
    
        @Override
        public List<Character> findAllCharacters() {
            List<Character> listCharacters = characRep.findAll();
            return listCharacters;
        }
    
        @Override
        public Character findCharactersById(long id) {
            Optional<Character> opt = characRep.findById(id);
            Character character = null;
            if(opt.isPresent()) {
                character = opt.get();
            }else {
                throw new RuntimeException("Character doesn't exist.");
            }
            return character;
        }
        
    
    } ```

Controlador:

```

Controlador:

    package com.alkemyApi.app.controller;
    
    import org.springframework.beans.factory.annotation.Autowired;
    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;
    
    import com.alkemyApi.app.service.ICharacterService;
    
    @RestController
    @RequestMapping(value = "character")
    public class CharacterController {
        
        @Autowired
        private ICharacterService characServ;
        
        @PostMapping("/save")
        public void saveCharacter(@RequestBody Character character) {
            characServ.saveCharacters(character);
            System.out.println("Character successfully saved");
        }
    
    }
 
```

Repositorio
```    

Repositorio

    package com.alkemyApi.app.controller;
    
    import org.springframework.beans.factory.annotation.Autowired;
    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;
    
    import com.alkemyApi.app.service.ICharacterService;
    
    @RestController
    @RequestMapping(value = "character")
    public class CharacterController {
        
        @Autowired
        private ICharacterService characServ;
        
        @PostMapping("/save")
        public void saveCharacter(@RequestBody Character character) {
            characServ.saveCharacters(character);
            System.out.println("Character successfully saved");
        }
    
    }
``` package com.alkemyApi.app.entity;

import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonManagedReference;

@Entity
@Table(name="characters")
public class Character {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id_character;
    
    @Basic
    private int age;
    private String image;
    private String history;
    private double weight;
    
    @JsonManagedReference
    @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinTable(name="characters_shooting",
    joinColumns = {@JoinColumn(name="id_character", nullable=false)},
    inverseJoinColumns= {@JoinColumn(name="id_shooting", nullable=false)})
    private List<Shooting> shootingList;

    public Character(long id_character, int age, String image, String history, double weight,
            List<Shooting> shootingList) {
        super();
        this.id_character = id_character;
        this.age = age;
        this.image = image;
        this.history = history;
        this.weight = weight;
        this.shootingList = shootingList;
    } 
 
Servicios;
Interfaz
```package com.alkemyApi.app.service;

import java.util.List;

public interface ICharacterService {

    public void saveCharacters(Character character);
    public void deleteCharacters(Character character);
    public List<Character> findAllCharacters();
    public Character findCharactersById(long id);
}
 ```

clase:
```package com.alkemyApi.app.service;

import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alkemyApi.app.repository.ICharacter;
@Service
public class CharacterService implements ICharacterService {

    @Autowired
    private ICharacter characRep;
    
    @Override
    public void saveCharacters(Character character) {
        characRep.save(character);
    }

    @Override
    public void deleteCharacters(Character character) {
        characRep.delete(character);
    }

    @Override
    public List<Character> findAllCharacters() {
        List<Character> listCharacters = characRep.findAll();
        return listCharacters;
    }

    @Override
    public Character findCharactersById(long id) {
        Optional<Character> opt = characRep.findById(id);
        Character character = null;
        if(opt.isPresent()) {
            character = opt.get();
        }else {
            throw new RuntimeException("Character doesn't exist.");
        }
        return character;
    }
    

} ```

Controlador:

```
package com.alkemyApi.app.controller;

import org.springframework.beans.factory.annotation.Autowired;
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;

import com.alkemyApi.app.service.ICharacterService;

@RestController
@RequestMapping(value = "character")
public class CharacterController {
    
    @Autowired
    private ICharacterService characServ;
    
    @PostMapping("/save")
    public void saveCharacter(@RequestBody Character character) {
        characServ.saveCharacters(character);
        System.out.println("Character successfully saved");
    }

}
 
```

Repositorio
``` 
package com.alkemyApi.app.controller;

import org.springframework.beans.factory.annotation.Autowired;
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;

import com.alkemyApi.app.service.ICharacterService;

@RestController
@RequestMapping(value = "character")
public class CharacterController {
    
    @Autowired
    private ICharacterService characServ;
    
    @PostMapping("/save")
    public void saveCharacter(@RequestBody Character character) {
        characServ.saveCharacters(character);
        System.out.println("Character successfully saved");
    }

}
package com.alkemyApi.app.entity;
    
    import java.util.List;
    
    import javax.persistence.Basic;
    import javax.persistence.CascadeType;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.JoinTable;
    import javax.persistence.ManyToMany;
    import javax.persistence.Table;
    
    import com.fasterxml.jackson.annotation.JsonManagedReference;
    
    @Entity
    @Table(name="characters")
    public class Character {
    
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        private long id_character;
        
        @Basic
        private int age;
        private String image;
        private String history;
        private double weight;
        
        @JsonManagedReference
        @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
        @JoinTable(name="characters_shooting",
        joinColumns = {@JoinColumn(name="id_character", nullable=false)},
        inverseJoinColumns= {@JoinColumn(name="id_shooting", nullable=false)})
        private List<Shooting> shootingList;
    
        public Character(long id_character, int age, String image, String history, double weight,
                List<Shooting> shootingList) {
            super();
            this.id_character = id_character;
            this.age = age;
            this.image = image;
            this.history = history;
            this.weight = weight;
            this.shootingList = shootingList;
        } 

Servicios; Interfaz

package com.alkemyApi.app.service;
    
    import java.util.List;
    
    public interface ICharacterService {
    
        public void saveCharacters(Character character);
        public void deleteCharacters(Character character);
        public List<Character> findAllCharacters();
        public Character findCharactersById(long id);
    }

Clase:

package com.alkemyApi.app.service;
    
    import java.util.List;
    import java.util.Optional;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    
    import com.alkemyApi.app.repository.ICharacter;
    @Service
    public class CharacterService implements ICharacterService {
    
        @Autowired
        private ICharacter characRep;
        
        @Override
        public void saveCharacters(Character character) {
            characRep.save(character);
        }
    
        @Override
        public void deleteCharacters(Character character) {
            characRep.delete(character);
        }
    
        @Override
        public List<Character> findAllCharacters() {
            List<Character> listCharacters = characRep.findAll();
            return listCharacters;
        }
    
        @Override
        public Character findCharactersById(long id) {
            Optional<Character> opt = characRep.findById(id);
            Character character = null;
            if(opt.isPresent()) {
                character = opt.get();
            }else {
                throw new RuntimeException("Character doesn't exist.");
            }
            return character;
        }
        
    
    } 

Controlador:

    package com.alkemyApi.app.controller;
    
    import org.springframework.beans.factory.annotation.Autowired;
    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;
    
    import com.alkemyApi.app.service.ICharacterService;
    
    @RestController
    @RequestMapping(value = "character")
    public class CharacterController {
        
        @Autowired
        private ICharacterService characServ;
        
        @PostMapping("/save")
        public void saveCharacter(@RequestBody Character character) {
            characServ.saveCharacters(character);
            System.out.println("Character successfully saved");
        }
    
    }
    

Repositorio

    package com.alkemyApi.app.controller;
    
    import org.springframework.beans.factory.annotation.Autowired;
    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;
    
    import com.alkemyApi.app.service.ICharacterService;
    
    @RestController
    @RequestMapping(value = "character")
    public class CharacterController {
        
        @Autowired
        private ICharacterService characServ;
        
        @PostMapping("/save")
        public void saveCharacter(@RequestBody Character character) {
            characServ.saveCharacters(character);
            System.out.println("Character successfully saved");
        }
    
    }
Origen Enlace

Error en SpringBoot creando una APIRest

escribo aquí para ver si pueden ayudarme con este error. No se que es lo que está mal, intente todo y no pude solucionarlo. Dejo mi codigo y el error

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. [2m2021-12-23 18:06:44.693[0;39m [31mERROR[0;39m [35m1084[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.boot.SpringApplication [0;39m [2m:[0;39m Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'characterController': Unsatisfied dependency expressed through field 'characServ'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'characterService': Unsatisfied dependency expressed through field 'characRep'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ICharacter' defined in com.alkemyApi.app.repository.ICharacter defined in @EnableJpaRepositories declared on AlkemyApiApplication: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class java.lang.Character at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.12.jar:5.3.12] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.12.jar:5.3.12] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.6.jar:2.5.6] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.6.jar:2.5.6] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.6.jar:2.5.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.6.jar:2.5.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.6.jar:2.5.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.6.jar:2.5.6] at com.alkemyApi.app.AlkemyApiApplication.main(AlkemyApiApplication.java:15) ~[classes/:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.5.6.jar:2.5.6] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'characterService': Unsatisfied dependency expressed through field 'characRep'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ICharacter' defined in com.alkemyApi.app.repository.ICharacter defined in @EnableJpaRepositories declared on AlkemyApiApplication: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class java.lang.Character at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656) ~[spring-beans-5.3.12.jar:5.3.12] ... 25 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ICharacter' defined in com.alkemyApi.app.repository.ICharacter defined in @EnableJpaRepositories declared on AlkemyApiApplication: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class java.lang.Character at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656) ~[spring-beans-5.3.12.jar:5.3.12] ... 39 common frames omitted Caused by: java.lang.IllegalArgumentException: Not a managed type: class java.lang.Character at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:582) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:85) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.(JpaMetamodelEntityInformation.java:75) ~[spring-data-jpa-2.5.6.jar:2.5.6] at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:66) ~[spring-data-jpa-2.5.6.jar:2.5.6] at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:228) ~[spring-data-jpa-2.5.6.jar:2.5.6] at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:178) ~[spring-data-jpa-2.5.6.jar:2.5.6] at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:161) ~[spring-data-jpa-2.5.6.jar:2.5.6] at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:72) ~[spring-data-jpa-2.5.6.jar:2.5.6] at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:319) ~[spring-data-commons-2.5.6.jar:2.5.6] at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:323) ~[spring-data-commons-2.5.6.jar:2.5.6] at org.springframework.data.util.Lazy.getNullable(Lazy.java:230) ~[spring-data-commons-2.5.6.jar:2.5.6] at org.springframework.data.util.Lazy.get(Lazy.java:114) ~[spring-data-commons-2.5.6.jar:2.5.6] at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:329) ~[spring-data-commons-2.5.6.jar:2.5.6] at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:144) ~[spring-data-jpa-2.5.6.jar:2.5.6] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.12.jar:5.3.12] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.12.jar:5.3.12] ... 49 common frames omitted

Mi entidad

``` package com.alkemyApi.app.entity;

import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonManagedReference;

@Entity
@Table(name="characters")
public class Character {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id_character;
    
    @Basic
    private int age;
    private String image;
    private String history;
    private double weight;
    
    @JsonManagedReference
    @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinTable(name="characters_shooting",
    joinColumns = {@JoinColumn(name="id_character", nullable=false)},
    inverseJoinColumns= {@JoinColumn(name="id_shooting", nullable=false)})
    private List<Shooting> shootingList;

    public Character(long id_character, int age, String image, String history, double weight,
            List<Shooting> shootingList) {
        super();
        this.id_character = id_character;
        this.age = age;
        this.image = image;
        this.history = history;
        this.weight = weight;
        this.shootingList = shootingList;
    } 

Servicios;
Interfaz
```package com.alkemyApi.app.service;

import java.util.List;

public interface ICharacterService {

    public void saveCharacters(Character character);
    public void deleteCharacters(Character character);
    public List<Character> findAllCharacters();
    public Character findCharactersById(long id);
}
 ```

clase:
```package com.alkemyApi.app.service;

import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alkemyApi.app.repository.ICharacter;
@Service
public class CharacterService implements ICharacterService {

    @Autowired
    private ICharacter characRep;
    
    @Override
    public void saveCharacters(Character character) {
        characRep.save(character);
    }

    @Override
    public void deleteCharacters(Character character) {
        characRep.delete(character);
    }

    @Override
    public List<Character> findAllCharacters() {
        List<Character> listCharacters = characRep.findAll();
        return listCharacters;
    }

    @Override
    public Character findCharactersById(long id) {
        Optional<Character> opt = characRep.findById(id);
        Character character = null;
        if(opt.isPresent()) {
            character = opt.get();
        }else {
            throw new RuntimeException("Character doesn't exist.");
        }
        return character;
    }
    

} ```

Controlador:

```
package com.alkemyApi.app.controller;

import org.springframework.beans.factory.annotation.Autowired;
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;

import com.alkemyApi.app.service.ICharacterService;

@RestController
@RequestMapping(value = "character")
public class CharacterController {
    
    @Autowired
    private ICharacterService characServ;
    
    @PostMapping("/save")
    public void saveCharacter(@RequestBody Character character) {
        characServ.saveCharacters(character);
        System.out.println("Character successfully saved");
    }

}

```

Repositorio
``` 
package com.alkemyApi.app.controller;

import org.springframework.beans.factory.annotation.Autowired;
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;

import com.alkemyApi.app.service.ICharacterService;

@RestController
@RequestMapping(value = "character")
public class CharacterController {
    
    @Autowired
    private ICharacterService characServ;
    
    @PostMapping("/save")
    public void saveCharacter(@RequestBody Character character) {
        characServ.saveCharacters(character);
        System.out.println("Character successfully saved");
    }

}

Gracias, espero su ayuda