测试报错 ,repository autowrited失败
来源:4-1 买家类目-dao(上)
qq_慕前端1318791
2021-05-22
No qualifying bean of type ‘com.codlz.sell.repository.ProductCategoryRepository’ available:
package com.codlz.sell.repository;
import com.codlz.sell.dataObjects.ProductCategory;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ProductCategoryRepository extends JpaRepository<ProductCategory, Integer> {
}
@RunWith(SpringRunner.class)
@SpringBootTest
public class ProductCategoryRepositoryTest {
@Autowired
private ProductCategoryRepository repository;
@Test
public void findOneTest() {
ProductCategory productCategory = repository.findOne(1);
System.out.println(productCategory.toString());
}
}
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: 123456
url: jdbc:mysql://192.168.2.11/sell?characterEncoding=utf-8&useSSL=false
jpa:
show-sql: true
@Entity
public class ProductCategory {
/*类目id*/
@Id
@GeneratedValue
private Integer categoryId;
/*类目名字*/
private String categoryName;
/*类目编号*/
private Integer categoryType;
public Integer getCategoryId() {
return categoryId;
}
public void setCategoryId(Integer categoryId) {
this.categoryId = categoryId;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public Integer getCategoryType() {
return categoryType;
}
public void setCategoryType(Integer categoryType) {
this.categoryType = categoryType;
}
@Override
public String toString() {
return "ProductCategory{" +
"categoryId=" + categoryId +
", categoryName='" + categoryName + '\'' +
", categoryType=" + categoryType +
'}';
}
}
写回答
1回答
-
廖师兄
2021-05-25
程序启动程序启动正常吗?
ProductCategoryRepositoryTest 是在什么包路径下呢
00
相似问题