小编Dou*_*uma的帖子

Thymeleaf webflux:仅允许将一个数据驱动变量指定为模型属性,但至少已识别两个

我正在尝试创建一个仪表板应用程序,其中多个小部件通过 SSE 获取更新。我的 DashboardController 看起来像:

public class DashboardController
{
    private WidgetService widgetService;

    public DashboardController(WidgetService widgetService)
    {
        this.widgetService = widgetService;
    }

    @GetMapping("/")
    public String index(final Model model)
    {
        for(WidgetInterface<?> widget : widgetService.getAll()) {
            model.addAttribute("widget-data-driver-" + widget.getIdentifier(),
                    new ReactiveDataDriverContextVariable(widget.getInitialData(), 100));
        }
        model.addAttribute("widgets", widgetService.getAll());
        return "index";
    }
}
Run Code Online (Sandbox Code Playgroud)

和我的小部件界面:

public interface WidgetInterface<T>
{
    public String getIdentifier();
    public String getTitle();
    public String getStreamEndpoint();
    public Flux<T> getInitialData();
    public Map<String, String> getColumns();
    public String getThymeLeafFraction();
    public Date getLastItemDate();
    public Flux<T> getItemsUpdatedSince(Date date);
}
Run Code Online (Sandbox Code Playgroud)

一个小部件(来自 WidgetService)一切正常。我正在尝试将ReactiveDataDriverContextVariable …

java spring reactive-programming thymeleaf spring-webflux

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

服务“admin.category”依赖于不存在的服务“sonata.admin.manager.orm”

为了在 Symfony 3 中设置 Sonata 管理员,我遵循了确切的说明: https://symfony.com/doc/3.x/bundles/SonataAdminBundle/getting_started/creating_an_admin.html

在步骤 3 中,我已输入所述的确切配置: https://symfony.com/doc/3.x/bundles/SonataAdminBundle/getting_started/creating_an_admin.html#step-3-register-the-admin-class

services:
    # ...
    admin.category:
        class: App\Admin\CategoryAdmin
        arguments: [~, App\Entity\Category, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: Category }
Run Code Online (Sandbox Code Playgroud)

但现在我收到以下错误:

The service "admin.category" has a dependency on a non-existent service "sonata.admin.manager.orm".  
Run Code Online (Sandbox Code Playgroud)

symfony sonata

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

为什么会编译?覆盖方法不是异常的子类

我很难理解为什么以下代码不是异常的子类,但为什么会编译:

class Test 
{
    public void run() throws IOException 
    {
        System.out.println("Test");
    }
}

class SubTest extends Test 
{
    //not a subclass of IOException, still compiles 
    public void run() throws RuntimeException 
    {
        System.out.println("Test from sub");
    }
}

class Sub2Test extends Test 
{
    //not a subclass of IOException, does not compile
    public void run() throws Exception  
    {
        System.out.println("Test from sub");
    }
}
Run Code Online (Sandbox Code Playgroud)

我知道这RuntimeException是一个未经检查的异常,但是我认为规则是它必须是父异常的子类?

java exception

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

Hibernate 通过持久属性的反射访问字段 [private java.lang.String com.example.demo.Student.firstName] 时出错

我有一个非常简单的 Hibernate 设置,但是在保存实体时收到这个奇怪的错误:

org.hibernate.property.access.spi.PropertyAccessException:通过持久属性 [com.example.demo.Student#firstName] 的反射访问字段 [private java.lang.String com.example.demo.Student.firstName] 时出错:Student [id=0,名字=我的,姓氏=姓名]

这就是我保存它的方式:

StudentDao studentDao = new StudentDao();
Student student = new Student("My", "Name");
studentDao.saveStudent(student);
Run Code Online (Sandbox Code Playgroud)

这是我的学生实体:

package com.example.demo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "student")
public class Student {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private int id;
    @Column(name = "first_name")
    private String firstName;
    @Column(name = "last_name")
    private String lastName;
    public Student() {
    }
    public Student(String firstName, String lastName) {
        this.firstName …
Run Code Online (Sandbox Code Playgroud)

java hibernate

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