我有一个简单的实体,由两个 UUID 组成:
\n@Table("library")\npublic class LibraryDao {\n @Id\n private UUID id;\n @NonNull\n private UUID ownerId;\n}\n
Run Code Online (Sandbox Code Playgroud)\n我在 PostgreSQL 中有一个对应的表:
\nCREATE TABLE IF NOT EXISTS library (id UUID PRIMARY KEY, owner_id UUID NOT NULL);\n
Run Code Online (Sandbox Code Playgroud)\n我正在使用正确的 R2DBC 驱动程序(io.r2dbc:r2dbc-postgresql
和org.postgresql:postgresql
)。
至此,一切正常。我的应用程序运行。但是\xe2\x80\xa6
\n因为 PostgreSQL 至少根据文档 \xe2\x80\x93 没有 UUID 自动生成功能,所以我在创建新实例时设置了 id LibraryDao
。
但是,当我save
在存储库中调用该方法时,出现异常:Failed to update table [library]. Row with Id [0ed4d7c0-871a-4473-8997-4c9c1ec67a00] does not exist.
似乎save
被解释为,如果它不存在则update
不会回退。insert
我试图检测focus
元素的子元素,以contenteditable
实现纯CSS样式。(我知道我可以使用JS来检测到这一点,添加一个额外的类并以这种方式进行操作,但这太漫长了。)
基本上,我有一些类似的东西:
<div contenteditable="true">
Some text <span class="edit">that</span> goes here.
</div>
Run Code Online (Sandbox Code Playgroud)
我按照以下方式尝试了CSS:
.edit:focus {
color: #FF0000;
}
Run Code Online (Sandbox Code Playgroud)
我希望span
当插入符插入时改变颜色,但显然焦点仅应用于的div
设置contenteditable
,而不应用于其任何子级。我曾尝试对施加一秒钟contenteditable
的时间span
,但除了采取一种非常草率的方法外,它还是无法正常工作。
这个问题有方法解决吗?
我有一个User
相关的限时Role
s。我想知道 a 是否User
有特定的UserRole
且未过期。我可以将用户的角色转换为流,filter()
它和findFirst()
,给我一个Optional
.
角色
public class Role {
private UserRole role;
private Date expiry;
public boolean isUnexpired () {
return (expiry == null) ? true : expiry.after(new Date());
}
}
Run Code Online (Sandbox Code Playgroud)
用户
public class User {
//...
private Collection<Role> roles
public boolean hasRole (UserRole userRole) {
return roles.stream()
.filter(r -> r.getRole().equals(userRole))
.findFirst()
.ifPresent(ur -> { /* ... herein the problem ... */ ur.isUnexpired(); } );
} …
Run Code Online (Sandbox Code Playgroud) 我正在尝试理解 Spring 授权服务器。
\n遵循各种教程和原始文档,几乎是配置依赖项 \xe2\x80\x93 后的第一步
\ndependencies {\n implementation 'org.springframework.boot:spring-boot-starter-webflux'\n implementation 'org.springframework.boot:spring-boot-starter-security'\n implementation 'org.springframework.security:spring-security-oauth2-authorization-server:0.2.1'\n// other db/test stuff\n}\n
Run Code Online (Sandbox Code Playgroud)\n@EnableAuthorizationServer
\xe2\x80\x93 是为主类添加注解。
除了我的 IDE (NetBeans) 没有从导入中得知它指的是什么。
\n那么:导入路径应该用于什么@EnableAuthorizationServer
?(而且,从逻辑上讲,是否还需要一些其他依赖项才能识别它?)