如果我有一个NxN矩阵
vector< vector<int> > A;
Run Code Online (Sandbox Code Playgroud)
我应该如何初始化它?
我试过没有成功:
A = new vector(dimension);
Run Code Online (Sandbox Code Playgroud)
既不是:
A = new vector(dimension,vector<int>(dimension));
Run Code Online (Sandbox Code Playgroud) 我有一个使用过滤器进行搜索的方法,所以我使用Specification来构建动态查询:
public Page<Foo> searchFoo(@NotNull Foo probe, @NotNull Pageable pageable) {
Specification<Foo> spec = Specification.where(null); // is this ok?
if(probe.getName() != null) {
spec.and(FooSpecs.containsName(probe.getName()));
}
if(probe.getState() != null) {
spec.and(FooSpecs.hasState(probe.getState()));
}
//and so on...
return fooRepo.findAll(spec, pageable);
}
Run Code Online (Sandbox Code Playgroud)
有可能没有指定过滤器,所以我会列出所有没有过滤的东西.那么考虑到这一点,我应该如何初始化spec
?现在,上面的代码不起作用,因为它总是返回相同的结果:表的所有寄存器,没有过滤已经做过and
操作.
FooSpecs:
public class PrescriptionSpecs {
public static Specification<Prescription> containsCode(String code) {
return (root, criteriaQuery, criteriaBuilder) ->
criteriaBuilder.like(root.get(Prescription_.code), "%" + code + "%");
}
// some methods matching objects...
public static Specification<Prescription> hasContractor(Contractor contractor) {
return (root, …
Run Code Online (Sandbox Code Playgroud) 我是 Yocto 项目的新手。最初的想法是基于core-image-full-cmdline
(这是没有窗口系统的)创建一个自定义图像,并针对该图像生成一个 Qt5 SDK。
$ bitbake my_image -c populate_sdk
会产生my_image
与QT5支持+ SDK安装?据我了解,要获得 Qt SDK,步骤是:
下载并添加meta-qt5
到 bblayers.conf。
添加到要构建 SDK 的图像配方中:
inherit populate_sdk_qt5
EGLFS
支持,没有 X11/Wayland 和 Qtwebkit(还有 idk,也许还有一些我还不知道的其他功能)。bitbake my_image -c populate_sdk
虽然我有这个,但我的构建在编译 wayland 时出错:
DISTRO_FEATURES_remove = "x11 wayland"
关于Yocto项目常见问题:
Yocto Project和OpenEmbedded共享一个名为openembedded-core的核心元数据集合.但是,这两个组织仍然是分开的,每个组织都有自己的重点.OpenEmbedded为各种体系结构,功能和应用程序提供了一整套元数据.Yocto项目致力于为核心架构和特定板提供功能强大,易于使用,可互操作,经过良好测试的工具,元数据和板级支持包(BSP).
我还没有得到任何清楚.这两个框架旨在构建Linux发行版.但我想知道它们具体区别于什么.不仅在技术上,而且在客观上,所以我可以争论为什么选择一个或另一个.
而且,为什么Yocto如此突出?尽管OE是第一个构建框架.
ps:我曾与Yocto Project合作过,但与OE合作过.
使用MapStruct。举个例子:
class Dto {
DtoA a;
DtoB b;
}
class DtoA {
Long id;
//...
}
class DtoB {
Long id;
//...
}
class Entity {
AB ab;
}
Run Code Online (Sandbox Code Playgroud)
如何映射DtoA
,并DtoB
以AB?
我试过了:
public abstract Entity toEntity(Dto dto);
@Mappings({
@Mapping(source = "a", target = "ab.a"),
@Mapping(source = "b", target = "ab.b")
)}
public abstract AB toABEntity(DtoA a, DtoB b);
Run Code Online (Sandbox Code Playgroud)
已经生成了toABEntity
足够的代码*,但未调用该方法。
*很糟糕,因为它首先设置a
,然后设置b
会创建的新实例ab
,因此a
会丢失。
取一个已转换为 的 JSON Map<String, Object>
:
{
"key1": "value1",
"key2": {
"nestedKey1": "nested value",
"nestedKey2": {
"nestedKey1": "nested value"
}
}
}
Run Code Online (Sandbox Code Playgroud)
其中Object
value 可以是某种原始类型或嵌套的Map<String, Object>
. 我的目标是获得一张平面地图:
{
"key1": "value1",
"key2.nestedKey1": "nested value",
"key2.nestedKey2.nestedKey1": "nested value"
}
Run Code Online (Sandbox Code Playgroud)
如何?任何已经这样做的图书馆?
按照官方文档,我正在尝试这样做:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
QThread *thread = new QThread;
Worker *worker= new Worker();
worker->moveToThread(thread);
//init connections
thread->start();
}
Run Code Online (Sandbox Code Playgroud)
工人构造函数:
Worker::Worker(QObject *parent) :
QObject(parent)
{
serial = new QSerialPort(this); //passing the parent, which should be the current thread
}
Run Code Online (Sandbox Code Playgroud)
没有编译错误但是当我执行它时会抛出这个:
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QSerialPort(0x11bd1148), parent's thread is QThread(0x11bd2ef8), current thread is QThread(0x3e47b8)
Run Code Online (Sandbox Code Playgroud)
也就是说,它告诉我serial
作为父线程的主线程而不是我创建的线程.
如果我不在构造函数中实例化序列但在主进程中实例化相同的结果,这是在我们调用之后触发的thread->start()
:
Worker::Worker(QObject *parent) :
QObject(parent)
{
}
Worker::doWork()
{
if(!serial) …
Run Code Online (Sandbox Code Playgroud) 我正在使用 mongodb,所以我将实体与创建 DTO(使用休眠验证器注释)的表示层分离。
public abstract class UserDTO {
private String id;
@NotNull
protected String firstName;
@NotNull
protected String lastName;
protected UserType type;
protected ContactInfoDTO contact;
protected List<ResumeDTO> resumes;
public UserDTO(){}
//...
Run Code Online (Sandbox Code Playgroud)
我正在尝试从 db 这个具体的类中检索
public class UserType1DTO extends UserDTO {
private CompanyDTO company;
public UserType1DTO(){
super();
}
public UserType1DTO(String firstName, String lastName, ContactInfoDTO contact, CompanyDTO company) {
super(UserType.type1, firstName, lastName, contact);
this.company = company;
}
/...
Run Code Online (Sandbox Code Playgroud)
像这样:
return mapper.map((UserType1) entity,UserType1DTO.class);
Run Code Online (Sandbox Code Playgroud)
我收到关于无法实例化的错误 ResumeDTO
Failed to instantiate instance of destination *.dto.ResumeDTO. Ensure …
Run Code Online (Sandbox Code Playgroud) 我的旅程开始于我尝试配置MongoDB的Java驱动程序以使用UUID v4而不是默认设置的Legacy UUID v3.
我在这里找到了这个解决方案https://groups.google.com/forum/#!msg/mongodb-user/ZJKQpMpCMU4/dW5ATHTcAvgJ.
但正如他所说:
请注意,使用旧版API时,将忽略编解码器注册表,因此不会使用重写的UUIDCodec
它不适用于我的MongoRepositoy
.
这是我的实际配置:
@Bean
public MongoDbFactory mongoDbFactory() throws Exception {
ServerAddress server = new ServerAddress(host,port);
MongoClientOptions.Builder mcoBuilder = MongoClientOptions.builder();
CodecRegistry codecRegistry = fromRegistries(fromCodecs(new UuidCodec(UuidRepresentation.STANDARD)),
MongoClient.getDefaultCodecRegistry());
mcoBuilder.codecRegistry(codecRegistry).build();
MongoClientOptions options = mcoBuilder.build();
MongoClient mongoClient = new MongoClient(server,options);
return new SimpleMongoDbFactory(mongoClient, mongoDataBase);
}
@Bean
public MongoTemplate mongoTemplate() throws Exception {
MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory());
return mongoTemplate;
}
Run Code Online (Sandbox Code Playgroud)
如果我做:
mongoClient.getDatabase(mongoDataBase).getCollection("test")
.insertOne(new Document("_id",UUID.randomUUID()));
Run Code Online (Sandbox Code Playgroud)
我明白了:
{ "_id" : BinData(4,"f0u8ig4TS6KaJGK93xmvNw==") }
Run Code Online (Sandbox Code Playgroud)
除此以外:
mongoTemplate.getCollection("test")
.insert(new BasicDBObject("_id", UUID.randomUUID())); …
Run Code Online (Sandbox Code Playgroud) 我正在尝试扩展我们的 Jenkins 工作(构建整个项目)以将构建的工件部署到我们的 Artifactory,但随后我遇到了一些与工件版本控制相关的问题。如果我尝试重新部署版本未更改的工件(不是快照),则会收到错误 403(用户 'foo' 需要 DELETE 权限),这是可以理解的,我不应该替换已发布的工件。如果工件版本包含-SNAPSHOT
则没有问题,它总是被上传。我的问题是:我们应该如何处理在 Artifactory 中锁定覆盖的情况?
java ×4
c++ ×2
mongodb ×2
qt ×2
yocto ×2
artifactory ×1
dynamicquery ×1
embedded ×1
java-8 ×1
jenkins ×1
mapstruct ×1
modelmapper ×1
openembedded ×1
qtcore ×1
qthread ×1
qtserialport ×1
spring-boot ×1
spring-data ×1
vector ×1
versioning ×1