Estou começando aprender Spring e estou recebendo esse erro, já fiz diversas pesquisas na internet porém até o momento não entendi o que está causando o problema:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'transactionController' defined in file [/Users/seuvito/Projetos/meubolso/target/classes/com/financas/meubolso/transaction/TransactionController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'transactionServiceImpl': Unsatisfied dependency expressed through field 'transactionRepoCustom'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionRepoCustom' defined in com.financas.meubolso.transaction.TransactionRepoCustom defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract void com.financas.meubolso.transaction.TransactionRepoCustom.deleteTransactionId(java.lang.String)! No property deleteTransactionId found for type Transaction!
Classe:
package com.financas.meubolso.transaction;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
@Getter
@Setter
@Entity
@Table
public class Transaction {
@Id()
@Column(name = "id")
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
private String id;
@Column(name = "title")
private String title;
@Column(name = "amount")
private Double amount;
@Column(name = "category")
private String category;
@Column(name = "type")
private String type;
public Transaction() {
}
public Transaction(String title, Double amount, String category, String type) {
this.title = title;
this.amount = amount;
this.category = category;
this.type = type;
}
public Transaction(String id, String title, Double amount, String category, String type) {
this.id = id;
this.title = title;
this.amount = amount;
this.category = category;
this.type = type;
}
@Override
public String toString() {
return "Transaction{" +
"id='" + id + '\'' +
", title='" + title + '\'' +
", amount=" + amount +
", category='" + category + '\'' +
", type='" + type + '\'' +
'}';
}
}
Contoller:
package com.financas.meubolso.transaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping(path = "api/v1/transactions")
public class TransactionController {
private TransactionServiceCustom transactionServiceCustom;
@Autowired
public void setTransactionService(TransactionServiceCustom transactionServiceCustom) {
this.transactionServiceCustom = transactionServiceCustom;
}
@Autowired
public TransactionController(TransactionServiceCustom transactionServiceCustom) {
this.transactionServiceCustom = transactionServiceCustom;
}
@RequestMapping(value = "transaction", method = RequestMethod.GET)
public List<Transaction> ShowAllTransaction(TransactionServiceCustom transactionServiceCustom) {
return transactionServiceCustom.getTransaction();
}
}
Service:
package com.financas.meubolso.transaction;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public interface TransactionServiceCustom {
void addTransaction(Transaction transaction);
List<Transaction> getTransaction();
}
Service Impl
package com.financas.meubolso.transaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class TransactionServiceImpl implements TransactionServiceCustom {
@Autowired
private TransactionRepoCustom transactionRepoCustom;
@Transactional
public void addTransaction(Transaction transaction) {
transactionRepoCustom.saveAndFlush(transaction);
}
@Transactional
public List<Transaction> getTransaction() {
return List.of(
new Transaction(
"id",
"aluguel",
10.00,
"habitacao",
"despesa"
)
);
}
}
Repositório
package com.financas.meubolso.transaction;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public interface TransactionRepoCustom extends JpaRepository<Transaction, String> {
void deleteTransactionId(String id);
Optional<Transaction> findTransactionById(String id);
}
fico muito grato caso alguém consiga me ajudar o que está errado no meu código.