Reputation: 376
Error creating bean with name 'clienteRestController': Unsatisfied dependency expressed through field 'clientService'.
Error creating bean with name 'clientServiceImpl': Unsatisfied dependency expressed through field 'clientDao'.
Error creating bean with name 'IClienteDao': Invocation of init method failed.
nested exception is java.lang.IllegalArgumentException: Not a managed type: class java.lang.Package
I am use eclipse with spring boot project with MySQL Database, when i run the project i see this error, i see some solves in stack Overflow but not worked , can any body help, thanks
@Entity
@Table(name = "package")
public class Package implements Serializable{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private int count;
@Column(precision=18, scale=2) /** Number (16, 2) **/
private double price;
@Column(name = "createAt")
@Temporal(TemporalType.TIMESTAMP)
private Date createAt;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public Date getCreateAt() {
return createAt;
}
public void setCreateAt(Date createAt) {
this.createAt = createAt;
}
private static final long serialVersionUID = 1L;
}
Controller "ClienteRestController":
@CrossOrigin(origins = {"http://localhost:4200"})
@RestController
@RequestMapping("/apiHorsesClub")
public class ClienteRestController {
@Autowired
private IClienteService clientService;
@GetMapping("clients")
public List<Package> index()
{
return clientService.findAll();
}
}
DAO layer "clientDao":
public interface IClienteDao extends CrudRepository<Package, Long>{
}
Service layer "IClienteService" : public interface IClienteService {
public List<Package> findAll();
}
implementation the service "ClientServiceImpl " :
@Service
public class ClientServiceImpl implements IClienteService {
@Autowired
private IClienteDao clientDao;
@Override
@Transactional(readOnly = true)
public List<Package> findAll() {
return (List<Package>) clientDao.findAll();
}
}
Upvotes: 0
Views: 753
Reputation: 376
Thanks all, i resolved the problem. the problem in name of the entity "Package", its reserved in Java 😂
Upvotes: 1