小编v.l*_*nev的帖子

在java中解码SVG图像文件(编码为base64)

我有SVG文件编码为base64,我想用ImageView显示图像.这是我试过的:

// imageBase64 is string that represents the SVG image encoded as base64    
byte[] decodedString = Base64.decode(imageBase64, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
Run Code Online (Sandbox Code Playgroud)

但decodeByte总是返回null.

PS:

  • 此代码适用于jpeg图像.
  • 如果base64字符串包含base64前缀("data:image/svg + xml; base64"或"data:image/jpeg; base64"),则decodingByte也始终返回null
  • base64字符串是正确的(它在HTML和其他base64在线工具中很好用)

java base64 svg android

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

密钥斗篷,如果选择了更新密码操作,则不返回访问令牌

我打电话/auth/realms/master/protocol/openid-connect/token通过在正文中发送以下内容来获取访问令牌, grant_type=password&client_id=example-docker-jaxrs-app&username=user&password=password&client_secret=1d27aedd-11c2-4ed2-97d5-c586e1f9b3cd

但是当我通过密钥斗篷管理控制台向用户输入更新密码作为必需操作时,尝试通过上述api获取令牌时出现以下错误,

{
    "error": "invalid_grant",
    "error_description": "Account is not fully set up"
}
Run Code Online (Sandbox Code Playgroud)

还有一件事,“临时密码”和“更新密码”这两项设置有什么区别?

用户凭据标签中的临时标志

在用户详细信息选项卡中根据需要更新密码

keycloak keycloak-services

6
推荐指数
2
解决办法
4403
查看次数

为什么在配置文件中定义类时需要@Entity Annotation

我是Hibernate的新手.我正在阅读一些教程,我发现如果我们在hibernate配置文件中添加模型类,我们仍然需要@Entity在模型类中添加注释.

为什么会这样?

java hibernate

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

我们可以检查休眠条件别名已经存在吗?

几分钟前收到错误“重复别名”,我开始思考“我们可以检查别名是否已经创建?别名已经存在。”

你知道吗?我们可以检查一下吗?

例如 :

Criteria criteria = getSeession().createCriteria(Example.class,"example");
criteria.createAlias("example.test","test");
Run Code Online (Sandbox Code Playgroud)

现在我想要这个,我会检查这个“测试”别名是否已经创建,我不会创建,我不会创建。

那可能吗?如果那可能怎么办?如果不可能,你能提供任何其他解决方案吗?

java hibernate hibernate-criteria

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

带有 Hibernate 的泛型

以下类无法使用 Hibernate 加载

package com.project.alice.entities;

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

import com.fasterxml.jackson.annotation.JsonProperty;

@Table
@Entity
 public class AnyInformation<T, K> {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@JsonProperty("id")
private long id;
@JsonProperty("parent")
@ManyToOne
private T parent;
@ManyToOne
@JsonProperty("parentType")
private K parentType;
@JsonProperty("informationType")
private String informationType;
@JsonProperty("information")
private String information;

public long getId() {
    return id;
}

public void setId(long id) {
    this.id = id;
}

public T getParent() {
    return parent;
}

public void setParent(T parent) { …
Run Code Online (Sandbox Code Playgroud)

java hibernate jpa

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

Spring Data JPA:如何编写具有 IN 运算符的子查询

我是新手Spring Data JPA,想知道如何编写以下子查询:

select o from Owner o where o.ownerId IN (Select c.ownerId from Cars c)
Run Code Online (Sandbox Code Playgroud)

Owner是一个实体类和Cars另一个实体类,我将拥有两个存储库,一个 asOwnerRepository和另一个 as CarRepository,都扩展JPARepository.

使用IN运算符编写此类自定义查询所需的帮助。

提前致谢。

java spring jpa spring-data spring-data-jpa

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

如何从测试中排除@EnableJpaRepositories?

我有一个 main@SpringBootApplication需要扫描特定的包才能启用 JPA 存储库,因此我使用@EnableJpaRepositories它来指定它。现在我正在实现单元测试,我只想测试控制器组件,所以我按照官方文档中的教程进行操作,他们使用@WebMvcTest(MyController.class)服务依赖项来测试控制器。问题是这对我不起作用,因为它试图加载我在主 Spring Boot 应用程序中指定的 JpaRepositories (当我@EnableJpaRepositories在主类中注释时,测试运行没有问题)。

我猜我需要为测试类创建一个特定的配置,这样它就可以忽略主要配置(因为我只想加载控制器并模拟服务层),但我不知道如何创建这样的配置。我尝试添加一个空配置,但它仍然失败并出现相同的错误:

@TestConfiguration
static class TestConfig {}
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'failureTaskHandler': Unsatisfied dependency expressed through field 'myManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'msgManager': Unsatisfied dependency expressed through field 'inboundManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'inboundManager': Unsatisfied dependency expressed through field 'messageRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name …
Run Code Online (Sandbox Code Playgroud)

java unit-testing spring-data spring-mvc-test spring-boot

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

使用 PostgreSQL 和 Spring Boot 项目创建名称为entityManagerFactory的bean时出错

当我尝试编译项目时出现错误

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-02-11 15:21:24.256 ERROR 14192 --- [           main] o.s.boot.SpringApplication               : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBuilder' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactoryBuilder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with …
Run Code Online (Sandbox Code Playgroud)

java hibernate jpa spring-boot

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

线程"main"中的异常java.lang.NoSuchMethodError:javax.persistence.Table.indexes()[Ljavax/persistence/Index;

如果我@Table从代码中删除注释,代码运行成功,我已经检查了与此错误相关的所有其他问题,但无法找到任何解决方案.

UserDetails.java

package org.javabrains.faisal.dto;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="USER_DETAILS")
public class UserDetails {

    @Id
    private int userId;

    public Date getJoinDate() {
        return joinDate;
    }

    public void setJoinDate(Date joinDate) {
        this.joinDate = joinDate;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    private String userName;

    private Date joinDate;

    private String …
Run Code Online (Sandbox Code Playgroud)

java hibernate

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

休眠如何生成外键约束名称?

休眠如何生成外键约束名称?

如果我没有定义名称,休眠将生成类似这样的内容

CONSTRAINT fk_2ocepcfwpr1v18dg1ieoe6bau
Run Code Online (Sandbox Code Playgroud)

这个名字是怎么产生的?也许来自MD5字段名称的哈希值或类似的东西?我需要知道所有实例上的名称是否相等。

hibernate hbm2ddl

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

@ManyToOne 引用的 getId() 上的 LazyInitializationException

LazyInitializationException当我尝试访问分离实体的惰性 @ManyToOne 引用的 ID 时,我正面临着这种情况。我不想完全获取引用,而只需要 ID(它应该存在于原始对象中,以便以惰性/延迟方式获取引用)。

EntityA ea = dao.find(1) // find is @Transactional, but transaction is closed after method exits
ea.getLazyReference().getId() // here is get exception. lazyReference is a ManyToOne relation and so the foreight key is stored in EntityA side.
Run Code Online (Sandbox Code Playgroud)

换句话说,如何在不实际获取整个 LazyReference 的情况下访问 LazyReference 的 ID(实际上存在于 EntityA 的初始选择中)?

java hibernate lazy-loading many-to-one lazy-initialization

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

是c_str()在堆中分配内存?

最近我有c_str()的问题.下面是示例代码片段

#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
class har{

    public:
    string h;
    har(string str){
        h=str;
    }
};

int main(){


har *hg=new har("harish");
const char *ptr=hg->h.c_str();
delete hg;
cout<<ptr<<endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)

我得到输出"harish"....我已经销毁了对象,但我仍然得到输出..是c_str()再次在堆中分配内存.

c++

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