我想创建删除行SQL,但是当我运行项目时,出现错误, org.springframework.beans.factory.BeanCreationException:创建名称为“ contactUsRepository”的bean时出错:FactoryBean在对象创建时抛出异常;嵌套异常是java.lang.IllegalArgumentException:不是托管类型:com.oop2.contactus.model.ContactForm类
这是我的代码
ContactUsList.html
<a th:href="@{'/delete-contact-us/'+ ${contactForm.id}}">Delete</a>
MainController.java
@RequestMapping("/delete-contact-us/{id}")
public String deleteContactUs(@PathVariable(name = "id") int id) {
contactService.delete(id);
return "ContactUsList";
}
ContactService.java
public void delete(long id) {
contactRepository.deleteById(id);
}
ContactUsRepository.java
package com.oop2.contactus.repositories;
import com.oop2.contactus.model.ContactForm;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ContactUsRepository extends CrudRepository<ContactForm, Long> {
}