小编Rom*_*hok的帖子

类型参数“S”的推断类型“S”不在其范围内;应该扩展 'ua.com.store.entity.Country

我的 CountryServiceImpl 有问题,当我想在 CountryServiceImpl 中实现 findOne 方法时,它告诉我“类型参数 'S' 的推断类型 'S' 不在其范围内;应该扩展 'ua.com.store.entity.Country” .

我想自己修复,但我不明白这是什么意思。你能帮我解决这个问题吗?

谢谢你。

@Entity
@Getter
@Setter
@NoArgsConstructor
@ToString
public class Country {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;

    private String countryName;

    @OneToMany(mappedBy = "country")
    private Set<Brand> brands = new HashSet<Brand>();
}


public interface CountryDAO extends JpaRepository<Country, Integer> {

    @Query("from Country c where c.countryName=:name")
    Country findByCountryName(@Param("name") String name);
}


public interface CountryService {

    void save(Country country);
    void delete(Country country);
    List<Country> findAll();
    Country findOne(int id);
    Country findByCountryName(String name);
} …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc spring-boot

10
推荐指数
2
解决办法
3万
查看次数

thymeleaf 获得前 3 个对象

请你帮助我好吗。我想展示产品中的前 3 个对象,但我不知道它必须是什么样子。我尝试使用百里香序列,但它不起作用。也许有人可以暗示我如何做到这一点。

HTML:

<th:block th:each="product:${products}">

<a  th:class="production_Page" th:href="@{'product/'+${product.id}}"> <p 
th:text="${product.productName}"/></a>

<a th:class="production_Page" 
th:href="@{'productDelete/'+${product.id}}">Delete</a>

<a th:class="production_Page" 
th:href="@{'productEdit/'+${product.id}}">Edit</a>

<img  th:class="productImage" th:src="${product.pathImage}"/>
<br/>
</th:block>
Run Code Online (Sandbox Code Playgroud)

控制器:

@GetMapping("/products")
public String seeAllProductsIntoAList(Model model){
    model.addAttribute("products", productService.findAll());
    model.addAttribute("categories", categoryService.findAll());
    return "/productView/products";
}
Run Code Online (Sandbox Code Playgroud)

如果有人能提示我这个问题,那就太好了。

谢谢。

java spring spring-mvc thymeleaf spring-boot

1
推荐指数
1
解决办法
1262
查看次数

标签 统计

java ×2

spring ×2

spring-boot ×2

spring-mvc ×2

thymeleaf ×1