小编phi*_*611的帖子

使用 Hibernate 时 findByUuid() 在 MySQL-DB 中不起作用

我正在开发 Spring REST 服务(使用 Spring Data JPA),并且我的实体包含 java.util.UUID 类型的属性。我使用MySQL作为数据库,这会导致问题。到目前为止,除了 UUID 是查询一部分的存储库方法之外,一切都工作正常,例如: entityRepository.findByUuid(UUID uuid);

默认情况下,数据存储在二进制 (255) 列中。从存储库获取 UUID 工作正常,唯一的问题是在查询中使用 UUID,如 findByUuid() 中。它总是告诉我在数据库中找不到特定的 UUID。MariaDB 也会出现同样的问题。

我的服务与 H2-Database 一起正常工作。知道为什么 MySQL(和 MariaDB)有这个问题吗?

数据库配置:

spring.datasource.url=jdbc:mysql://localhost/abc123
spring.datasource.username=alfkmakfaf
spring.datasource.password=aafkmafmlaf
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.database=mysql
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
Run Code Online (Sandbox Code Playgroud)

实体中的 UUID

@Entity
public class Thema {
    // without any annotations, works fine with H2 Database
    private UUID uuid;
...
Run Code Online (Sandbox Code Playgroud)

java mysql spring hibernate spring-data-jpa

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

如何使用SystemJS在Angular2应用程序中加载bootstrap.js,jQuery和其他模块

我是angular2,npm和systemjs的新手,我无法弄清楚如何加载和使用下载的node_modules.假设我想先加载jQuery然后再加载bootstrap.我修改了我的systemjs但是有一些错误......

错误:

(索引):21错误:错误:Bootstrap的JavaScript需要jQuery(...)(匿名函数)@(索引):21ZoneDelegate.invoke @ zone.js:323Zone.run @ zone.js:216(匿名函数)@ zone.js :571ZoneDelegate.invokeTask @ zone.js:356Zone.runTask @ zone.js:256drainMicroTaskQueue @ zone.js:474ZoneTask.invoke @ zone.js:426(index):20错误:ReferenceError:模块未定义(...)

的index.html

<!doctype html>
<html>
  <head>
    <base href="/"/>
    <title>Angular 2 QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="styles.css">
    <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
    <!-- 1. Load libraries -->
     <!-- Polyfill(s) for older browsers -->
    <script src="node_modules/core-js/client/shim.min.js"></script>
    <script src="node_modules/zone.js/dist/zone.js"></script>
    <script src="node_modules/reflect-metadata/Reflect.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>
    <!-- 2. Configure SystemJS -->
    <script src="systemjs.config.js"></script>
    <script>
      System.import('app').catch(function(err){ console.error(err); });
      System.import('jQuery').catch(function(err){ console.error(err); });
      System.import('bootstrap').catch(function(err){ console.error(err); });
    </script>
    <!--<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>-->
  </head>
  <!-- …
Run Code Online (Sandbox Code Playgroud)

javascript npm systemjs

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

ubuntu 18.04 上的 c 文件中对“readline”的未定义引用(安装了 libreadline-dev,与“-lreadline”链接)

我知道 Stackoverflow 上有很多关于此问题的帖子,但没有一个解决方案对我有帮助。我正在使用 Ubuntu 18.04 以及开发人员通常需要的所有功能:build-essential, libreadline-dev, ...

\n\n

我看了一下,/usr/include/readline但 readline 肯定在那里!\ngcc 总是告诉我:

\n\n
\n

对“readline”的未定义引用

\n
\n\n

顺便说一下,无论我是否与“-lreadline”链接,这种情况都会独立发生。

\n\n
\n\n

编辑

\n\n

由于用户\xc2\xa0@Kamil Cuk 已经提供了简单的解决方案,我想添加更多信息:

\n\n
$ gcc -lreadline -o code code.c\n
Run Code Online (Sandbox Code Playgroud)\n\n

可在 MacOS 上与 apple-gcc(使用 clang)以及 gnu-gcc(通过 brew 安装)一起使用。仅在 Ubuntu 上,链接器标志必须位于“code.c”之后

\n\n

(也许是因为 Ubuntu 使用 gcc-7 而在我的 Mac 上我使用 gcc-8)

\n\n

编辑结束

\n\n
\n\n

代码.c

\n\n
#include <stdlib.h>\n#include <stdio.h>\n#include <readline/readline.h>\n\nint main(void) {\n    char * buffer = readline("enter sth: ");\n    printf("%s\\n", buffer);\n    printf("bye!\\n");\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n …

c ubuntu gcc readline

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

为什么 Rust 告诉“编译时大小未知”而不是(无效)切片到切片分配中的另一个错误?

我有一段看起来很奇怪的代码,我知道 Rust 编译器拒绝它,但我不明白具体的错误消息。

TL; 博士; 为什么 Rust 以“在编译时没有已知的大小”而不是“非法语法”或“不能将切片分配给切片”之类的东西拒绝这一点?

fn main() {
    let mut data1 = vec![0, 1, 2, 3].as_slice();
    let mut data2 = vec![8, 9].as_slice();
    data1[1..3] = *data2; // of course this is illegal; but I don't understand the error message
}
Run Code Online (Sandbox Code Playgroud)

这是代码。理论上它应该用 slice 中data1的数据替换子切片data2。(例如,正确的方法是 for 循环,我知道!)。但是让我们来看看这个。Rust 编译器说:

error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time
 --> src\main.rs:4:5
  |
4 |     data1[1..3] = *data2;
  |     ^^^^^^^^^^^ doesn't have a size …
Run Code Online (Sandbox Code Playgroud)

rust

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

我如何理解 Rust 编译器目标的数据布局字符串?

在 Rust 编译器内部,所有目标都有一个data_layout. 这根绳子看起来真的很可怕,让我做噩梦。它的例子是

e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:32-n8:16:32-a:0:32-S32
Run Code Online (Sandbox Code Playgroud)

e-m:e-i64:64-f80:128-n8:16:32:64-S128
Run Code Online (Sandbox Code Playgroud)

这里发生了什么?

rust

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

如何将 Rust 代码编译为裸机 32 位 x86 (i686) 代码?我应该使用什么编译目标?

我想使用 Cargo/Rust 编译 x86 的裸机 32 位代码(在 32 位模式下又称为 i686 或 x86_64)。我需要什么目标?在官方支持的目标列表中我找不到任何实用的东西。

rust

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

获取和设置单元格的值不起作用

我无法从电子表格中的单元格获取值。我在文档中找到了 getCell() 方法,但它不起作用。它总是只得到“范围”而不是值。(顺便说一句,它是一个整数。)而且我没有找到 setCell() 方法!oO 值位于单元格 B:1 中,如有任何帮助,谢谢!!1 :)

var API_KEY           = "***",
    PROFILE_ID        = "****";
    GET_PLUS_ONES_URI = "https://www.googleapis.com/plus/v1/people/"+PROFILE_ID+"?fields=plusOneCount&key="+API_KEY;
var currentPlusOnes = 0,
    lastPlusOnes    = 0,
    ss              = SpreadsheetApp.getActive();

function execute() {
  getCurrentPlusOnes();
  getLastPlusOnes();
  if ( currentPlusOnes !== getLastPlusOnes ) {
    setCurrentValue();
  }
}

function getCurrentPlusOnes() {
  currentPlusOnes = JSON.parse( UrlFetchApp.fetch( GET_PLUS_ONES_URI )).plusOneCount;
}

function getLastPlusOnes() {
  lastPlusOnes = ss.getRange("B1").getCell( 1, 1 ); // --> Allways just "Range" instead of the value
}

function setCurrentValue() {
  ss.getDataRange().setValue( currentPlusOnes );
}
Run Code Online (Sandbox Code Playgroud)

google-sheets google-apps-script

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

无法将数组传递给具有任意长度切片的 From 特征

我正在尝试为From<&[&str]>我的一种类型实现。它应该消耗任意长度的行(仅在运行时知道)并从行中获取数据。编译器抱怨这&[&str; 2]不是&[&str],即它无法将固定大小的切片转换为任意长度的切片。确切的消息是:the trait 'From<&[&str; 2]>' is not implemented for 'LineEater'

这是我的尝试:

fn main() {
    let data = ["foo", "bar"];
    
    // works
    foo(&data);

    // doesn't work
    LineEater::from(&data);

    // also doesn't work
    let data: &[&str] = data.into();
    LineEater::from(&data);
}

struct LineEater;
impl From<&[&str]> for LineEater {
    fn from(_lines: &[&str]) -> Self {
        todo!()
    }
}

fn foo(_slice: &[&str]) {}
Run Code Online (Sandbox Code Playgroud)

操场

令人困惑的是,这适用于 的调用foo()但不适用于 的调用from。在第一种情况下,Rust 可以“强制转换” [&str; 2]to&[&str]但不能在后者中“强制转换” 。为什么会这样,我该如何解决?

我每晚使用 …

rust

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

如何在不进行多次分配的情况下实现条件嵌套格式化?

我有一个由多个条件组件组成的格式字符串,我正在寻找一种不需要为中间步骤多次分配字符串的解决方案。如果我使用 -macro 创建最终格式字符串的每个单独组件,format!那么它可以工作,但我需要为每个组件进行分配。

我尝试尝试仅使用宏来生成复杂的格式字符串及其参数。但是,这总是会导致“在此语句结束时释放临时值”错误。我尝试使用单一类型的缓冲区impl core::fmt::Write,但我也无法成功。

在高层次上,我想要这样的东西:

fn main() {
    let prefix_include_a = true;
    let prefix_include_b = true;
    // prefix itself is a formatted string and it is further formatted here
    println!("{prefix:<10}{message:>10}!",
        prefix = format_prefix(prefix_include_a, prefix_include_b),
        message = "message"
    );
}

// formats the prefix component of the final string.
// needs multiple String allocations as `format!` is used
fn format_prefix(inc_a: bool, inc_b: bool) -> String {
    format!("[{a:<5}{b:<5}]",
        a = if inc_a {
            format!("{:.1}", 1.234)
        } else …
Run Code Online (Sandbox Code Playgroud)

formatting rust

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

除了Rust标准库之外,是否还有Sync trait的有效实现?

Sync并且Send是语言的一部分。ArcMutex是标准库的一部分,并且都实现SendSync。除了标准库(std::sync)之外,是否还有其他unsafe impl Sync for SomeStruct {}出于某种正当理由进行类似操作的结构?以我的愚见,Sync除开发标准库的开发人员外,没有开发人员将需要任何实现。

rust

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