小编Ami*_*bha的帖子

debug jdk source无法监视变量是什么

我正在调试JDK源代码:

 public static int codePointAt(CharSequence seq, int index) {
        char c1 = seq.charAt(index++);
        if (isHighSurrogate(c1)) {
            if (index < seq.length()) {
                char c2 = seq.charAt(index);
                if (isLowSurrogate(c2)) {
                    return toCodePoint(c1, c2);
                }
            }
        }
        return c1;
    }
Run Code Online (Sandbox Code Playgroud)

我想c1在进入之前看到变量if (isHighSurrogate(c1)).但是,当我调试监视c1变量时,它会显示:

在此输入图像描述

我真的尝试过添加rt.jar源代码,它确实可以进入JDK源代码的断点,如: 在此输入图像描述

但为什么c1变量无法显示?

java

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

shutdown和awaitTermination哪个第一次调用有什么区别?

有什么区别

ExecutorService eService = Executors.newFixedThreadPool(2);
eService.execute(new TestThread6());
eService.execute(new TestThread6());
eService.execute(new TestThread6());
eService.awaitTermination(1, TimeUnit.NANOSECONDS);
eService.shutdown();
Run Code Online (Sandbox Code Playgroud)

eService.shutdown();
eService.awaitTermination(1, TimeUnit.NANOSECONDS);
Run Code Online (Sandbox Code Playgroud)

我真的不明白shutdown().此方法不会等待先前提交的任务完成执行.这是否意味着shutdown()可以终止已提交但未完成的任务?我尝试了一些例子,他们没有证明,请举个例子.

java multithreading executorservice

37
推荐指数
5
解决办法
6万
查看次数

意外令牌附近的语法错误'然后'

我输入的代码与Linux命令行相同:完整介绍,第369页,但提示错误:

line 7 `if[ -e "$FILE" ]; then`
Run Code Online (Sandbox Code Playgroud)

代码如下:

#!/bin/bash
#test file exists

FILE="1"
if[ -e "$FILE" ]; then
  if[ -f "$FILE" ]; then
     echo :"$FILE is a regular file"
  fi
  if[ -d "$FILE" ]; then
     echo "$FILE is a directory"
  fi
else 
   echo "$FILE does not exit"
   exit 1
fi
   exit
Run Code Online (Sandbox Code Playgroud)

我想知道是什么引入了这个错误?我该如何修改代码?我的系统是Ubuntu.

unix linux shell

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

编译错误 len 作为 const fn 还不稳定

我从我的依赖项之一收到错误消息。这是错误的代码示例:bytes 0.5.2

pub const fn foo(foo: &'static [u8]) -> usize {
    foo.len()
}
Run Code Online (Sandbox Code Playgroud)
error: `core::slice::<impl [T]>::len` is not yet stable as a const fn
 --> <source>:2:5
  |
2 |     foo.len()
  |     ^^^^^^^^^
error: aborting due to previous error
Run Code Online (Sandbox Code Playgroud)
active toolchain
----------------

stable-x86_64-pc-windows-msvc (default) rustc 1.38.0 (625451e37 2019-09-23)
Run Code Online (Sandbox Code Playgroud)

rust

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

带有货车错误的 mvn 远程部署

我想使用 maven 进行远程部署并参考 我的 pom.xml文档

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"         
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.sonatype.mavenbook.multispring</groupId>
    <artifactId>simple-parent</artifactId>
    <packaging>pom</packaging>
    <version>1.0</version>
    <name>Multi-Spring Chapter Simple Parent Project</name>

    <modules>
        <module>common</module>
        <module>login</module>
        <module>dao</module>
    </modules>

    <distributionManagement>
        <repository>
            <id>ssh-repository</id>
            <url>scp://101.200.161.77/root/project/maven_test/</url>
        </repository>
    </distributionManagement>

    <build>
        <extensions>
            <!-- Enabling the use of SSH -->
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-ssh-external</artifactId>
                <version>2.4</version>
            </extension>
        </extensions>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
                <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>com.entry.Main</mainClass>
                            <classpathPrefix>lib/</classpathPrefix>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>package</phase> …
Run Code Online (Sandbox Code Playgroud)

maven

5
推荐指数
0
解决办法
2750
查看次数

Elasticsearch 如何支持涉及多个文档的事务

我使用弹性搜索和非规范化数据,比如

PUT /my_index/user/1
{
"name": "John Smith",
"email": "john@smith.com",
"dob": "1970/10/24"
}

PUT /my_index/blogpost/2
{
"title": "Relationships",
"body": "It's complicated...",
"user": {
"id": 1,
"name": "John Smith"
}
}
Run Code Online (Sandbox Code Playgroud)

但问题是 Elasticsearch 不支持 ACID 事务。对单个文档的更改是 ACIDic,但不是涉及多个文档的更改。如果我想在一次事务中更改 /my_index/user/1 和 /my_index/blogpost/2 用户名,如果出现错误将回滚,该怎么做?

elasticsearch

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

go 插入复合类型数组不支持的类型

sql

CREATE TABLE public.tiantang_page (
    href varchar NOT NULL,
    status int4 NOT NULL,
    description varchar NOT NULL,
    urls url[] NULL
);

CREATE TYPE url AS (
    url varchar,
    status int4);
Run Code Online (Sandbox Code Playgroud)

插入复合类型数组

type url  struct {
    url string
    status int 
}
    var urls [1]url
    urls[0] = url{
        url:    "",
        status: 0,
    }
    update := "UPDATE \"public\".\"tiantang_page\" SET \"urls\"=$1 where \"href\"=$2;"
    r, err := db.Exec(update, pq.Array(urls),href)
    if err != nil {
        log.Fatal(err)
    }
Run Code Online (Sandbox Code Playgroud)

错误

sql:转换参数 $1 类型:不支持的类型 parsetest.url,一个结构

图书馆

https://godoc.org/github.com/lib/pq
Run Code Online (Sandbox Code Playgroud)

postgresql go

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

创建挂载源路径 mkdir /host_mnt/d 时出错:文件存在

我运行 docker-compose up -d 报告错误

D:\project\c\test\docker>docker-compose up -d
Starting debug ... error

ERROR: for debug  Cannot start service gdbserver: error while creating mount source path '/host_mnt/d/project/c/test/docker': mkdir /host_mnt/d: file exists

ERROR: for gdbserver  Cannot start service gdbserver: error while creating mount source path '/host_mnt/d/project/c/test/docker': mkdir /host_mnt/d: file exists
ERROR: Encountered errors while bringing up the project.
Run Code Online (Sandbox Code Playgroud)

文件

FROM ubuntu:cosmic

########################################################
# Essential packages for remote debugging and login in
########################################################

RUN apt-get update && apt-get upgrade -y && apt-get install …
Run Code Online (Sandbox Code Playgroud)

docker dockerfile docker-compose

5
推荐指数
2
解决办法
6306
查看次数

java.lang.IllegalArgumentException:未知实体

我有一个测试驱动,

package com.chinalbs.service;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:applicationContext.xml" })
@Component
@TransactionConfiguration(defaultRollback = true)
@Transactional
public class TestConductor {

    @Resource(name = "conductorServiceImpl")
    private ConductorService cService;

    @Resource(name = "enterpriseToConductorServiceImpl")
    private EnterpriseToConductorService eToConductorService;

    @Test
    public void testSave() {
        Conductor willedSaved = getConductor();
        cService.save(willedSaved);
        Conductor saved = cService.find(willedSaved.getId());
        Assert.assertEquals(willedSaved, saved);
        cService.delete(saved);
        Conductor notExisted = cService.find(saved.getId());
        Assert.assertNotNull(notExisted);
    }
}
Run Code Online (Sandbox Code Playgroud)

而applicatin.xml是

<bean id="own" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
        <property name="driverClass" value="${jdbc.driver}" />
        <property name="jdbcUrl" value="${jdbc.url.own}" />
        <property name="user" value="${jdbc.username.own}" />
        <property name="password" value="${jdbc.password.own}" />
        <property name="initialPoolSize" value="${connection_pools.initial_pool_size}" />
        <property …
Run Code Online (Sandbox Code Playgroud)

spring hibernate jpa

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

特征 std::ops::Try 没有为 impl 实现

我克隆了https://gitlab.com/pwoolcoc/soup并运行了示例文件。一切正常,但是当我使用与示例文件相同的文件创建一个新项目时,我遇到了错误。代码是:

use std::collections::HashSet;
use std::fmt::Error;
use soup::Soup;
use reqwest;
fn main() -> Result<(), Box<Error>> {
    let resp = reqwest::get("https://docs.rs/soup/0.1.0/soup/")?;
    let soup = Soup::from_reader(resp)?;
    let result = soup
        .tag("section")
        .attr("id", "main")
        .find()
        .and_then(|section| {
            section
                .tag("span")
                .attr("class", "in-band")
                .find()
                .map(|span| span.text())
        });
    assert_eq!(result, Some("Crate soup".to_string()));
    Ok(())
}
Run Code Online (Sandbox Code Playgroud)

货物档案

[package]
name = "testquestion"
version = "0.1.0"
authors = ["wangyiran"]
edition = "2018"

[dependencies]
soup = "0.3"
reqwest =  { version = "0.10.0-alpha.2", features = ["blocking"] }
Run Code Online (Sandbox Code Playgroud)

错误:

use std::collections::HashSet;
use …
Run Code Online (Sandbox Code Playgroud)

rust

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

spring data jpa保存手动分配标识符

我用弹簧保存

  HighWay highWay = new HighWay();
     highWay.setId("000");
    HighWayRepository hRepository = (HighWayRepository) context
                    .getBean("highWayRepository");
            hRepository.save(highWay);
            hRepository.flush();


    public interface HighWayRepository extends JpaRepository<HighWay, String> {

    }
Run Code Online (Sandbox Code Playgroud)

该表就像 f_idvarchar(256) NOT NULL,

public class HighWay {
    @Id
    @Column(name="f_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private String id;}
Run Code Online (Sandbox Code Playgroud)

但抛出异常

引起原因:java.sql.SQLException:字段“f_id”在 com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946) 处没有默认值 com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO. java:2870)在com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)在com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1169)在com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement .java:693)在com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1404)在com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1318)在com.mysql.jdbc.PreparedStatement.executeUpdate( PreparedStatement.java:1303)在com.alibaba.druid.pool.DruidPooledPreparedStatement.executeUpdate(DruidPooledPreparedStatement.java:253)在org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)... 51更多的

我检查文档,Id-Property 检查(默认) 默认情况下,Spring Data JPA 检查给定实体的 Id-Property。如果 Id-Property 为空,则该实体将被假定为新的,否则被假定为非新的。

sql就像Hibernate:insert into us_highway (blockTime, blockType, endNum, predictTime, publishTime, roadName, situation, startNum, tips) values (?, ?, ?, ?, ?, ?, ?, ?, …

spring spring-data spring-data-jpa

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