小编Jas*_*ler的帖子

executorService.submit(Runnable)返回的future对象是否包含对runnable对象的任何引用?

我们假设我们有以下代码:

List<Future<?>> runningTasks;
ExecutorService executor;
...
void executeTask(Runnable task){
    runningTasks.add(executor.submit(task));
}
Run Code Online (Sandbox Code Playgroud)

我的问题是:

  1. 是否runningTasks持有task对象的引用?
  2. 它持有多长时间?任务完成后是否还能保留它?
  3. 为了避免内存泄漏,我是否必须小心删除添加到列表中的未来?

java future executorservice runnable

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

使用Docker桥接网络时,无法在集成测试中获取JDBC连接

当我在maven test本地运行时通过.但是当我在CI服务器上运行它时出现此错误.

Error Message
Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
Stacktrace
org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
Caused by: org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 
Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Caused by: java.net.UnknownHostException: mysql …
Run Code Online (Sandbox Code Playgroud)

java mysql spring jenkins docker

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

对mysql_init的未定义引用

我正在尝试在我的新服务器上编译我的程序,但目前它并不适合我.

错误日志是:

rasmus@web01:~/c++$ make test
g++ `mysql_config --cflags --libs` main.cpp logger.cpp cpulogger.cpp -o test
/tmp/ccPaMZUy.o: In function `CPULogger':
/home/rasmus/c++/cpulogger.cpp:7: undefined reference to `mysql_init'
/home/rasmus/c++/cpulogger.cpp:8: undefined reference to `mysql_real_connect'
/home/rasmus/c++/cpulogger.cpp:10: undefined reference to `mysql_get_client_info'
/tmp/ccPaMZUy.o: In function `~CPULogger':
/home/rasmus/c++/cpulogger.cpp:16: undefined reference to `mysql_close'
collect2: ld returned 1 exit status
make: *** [all] Error 1
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我正在编译MySQL - 我已经检查过包含路径中是否存在mysql.h.

我错过了什么?

cpulogger.cpp在顶部有#include"cpulogger.h",然后cpulogger.h有这个:

#include <iostream>
#include <fstream>
#include <mysql/mysql.h>
Run Code Online (Sandbox Code Playgroud)

编译器不会抱怨缺少mysql/mysql.h,那么该部分必须工作吗?

输出mysql_config:

rasmus@web01:~/c++$ mysql_config --cflags --libs
-I/usr/include/mysql -DBIG_JOINS=1  -fno-strict-aliasing  -g
-L/usr/lib -lmysqlclient -lpthread -lz -lm -lrt …
Run Code Online (Sandbox Code Playgroud)

c c++ linker

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

方法'X.set_DbConnection(System.Data.Common.DbConnection)'错误尝试访问方法'Y.get_Settings()'失败

我创建了一个控制台应用程序并使用EntityFramework 6.2(用于与MS SQL连接),MySql.Data 8.0.11和MySql.Data.Entity 6.10.7(用于与MySQL连接).

在这个应用程序中,我想创建一个类似SQL作业的作业,但我不想使用quertz.net.我有错误:

"尝试通过方法'MySql.Data.Entity.EFMySqlCommand.set_DbConnection(System.Data.Common.DbConnection)'来访问方法'MySql.Data.MySqlClient.MySqlConnection.get_Settings()'失败."

c# mysql entity-framework console-application

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

Flutter Bloc 不会更改 TextFormField 初始值

我正在使用 Bloc 库,并注意到在产生新状态后我的TextFormField初始值没有改变。

我的应用程序比这更复杂,但我做了一个最小的例子。还跟踪推送事件后状态的变化。

Bloc 应该正确重建整个小部件。我错过了什么吗?

import 'package:flutter/material.dart';
import 'package:bloc/bloc.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'dart:developer' as developer;

void main() {
  runApp(MyApp());
}

enum Event { first }

class ExampleBloc extends Bloc<Event, int> {
  ExampleBloc() : super(0);
  @override
  Stream<int> mapEventToState(Event event) async* {
    yield state + 1;
  }
}

class MyApp extends StatelessWidget {
  const MyApp({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: BlocProvider(
        create: (_) => ExampleBloc(),
        child: Builder(
          builder: (contex) => SafeArea(
            child: …
Run Code Online (Sandbox Code Playgroud)

flutter bloc flutter-bloc

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

如何在 Jetpack Compose 中实现这种布局

我正在尝试使用新的 Jetpack Compose UI 框架,但遇到了问题。我想实现这个布局,在 xml 中很容易实现:

正确布局

但我无法弄清楚如何使垂直分隔线占用可用的垂直空间,而不指定固定的高度。我尝试过的这段代码似乎不起作用:

@Composable
fun ListItem(item: PlateUI.Plate) {
    Surface(
        modifier = Modifier.fillMaxWidth(),
        shape = RoundedCornerShape(8.dp),
        elevation = 2.dp
    ) {
        Row(
            modifier = Modifier.fillMaxWidth(),
            verticalAlignment = Alignment.CenterVertically
        ) {
            Column(
                modifier = Modifier
                    .padding(8.dp),
                horizontalAlignment = Alignment.CenterHorizontally
            ) {
                Text(text = "Code")
                Text(text = item.code)
            }
            Spacer(
                modifier = Modifier
                    .preferredWidth(1.dp)
                    .background(color = MaterialTheme.colors.onSurface.copy(0.12f))
            )
            Spacer(modifier = Modifier.weight(1f))
            Text(
                modifier = Modifier
                    .padding(horizontal = 8.dp, vertical = 34.dp),
                text = item.name
            )
            Spacer(modifier = Modifier.weight(1f)) …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-jetpack-compose

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

Next.js global variables on server and client based on request domain

I am working on a Next.js multisite scoped project and I need to create a set of global variables to use on client and server (during SSR) side.

So far I came to the below solution.

This is how my custom App looks like:

import App from 'next/app'
import multisite from '@utils/multisite';
import MultisiteProvider from '@components/multisite/MultisiteProvider';

function MyApp({
  Component,
  site,
  pageProps
}) {
  // Will add site props to every page
  const props = { ...pageProps, site };
  return ( …
Run Code Online (Sandbox Code Playgroud)

reactjs next.js

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

哪个更好 - PostgreSQL prisma 模式的 Int autoincrement id 或 cuid?

我们在 Next.js 应用程序中使用 Postgres 和 prisma。以前的开发人员已经对我们架构上的每个表使用了cuid。由于某些原因,我们正在重组表,我想知道使用 int id 会更好吗?它会带来任何性能提升吗?

对于 Postgres prisma 客户端,使用 Int autoincrement id 与 cuid 之间的权衡是什么?

如果您开始比较 Postgres 的 GUID 与 Int id,请引用真实的参考资料,证明 cuid 已映射到 Postgres 的 guid。

javascript postgresql reactjs next.js prisma

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

Windows Phone 8.1模拟器未加载操作系统

我试图启动模拟器(模拟器8.1 WVGA 4英寸512 MB,或任何其他事实上)但它无法启动.

它进入"加载操作系统"屏幕然后抛出一个带有文本"DEP6100"的错误框.在VS上,它在底部说

Error1 Error : DEP6100 : The following unexpected error occurred during bootstrapping stage 'Connecting to the device': ObjectDisposedException - 0x80131622
Run Code Online (Sandbox Code Playgroud)

Error2 Error : DEP6100 : The following unexpected error occurred during bootstrapping stage 'Connecting to the device': ObjectDisposedException - 0x80131622
Run Code Online (Sandbox Code Playgroud)

在互联网上看,但尚未找到答案.你能帮忙吗?

请告诉我您需要哪些其他信息.

windows-phone-8 windows-phone-8-emulator visual-studio-2013

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

makefile - make:*** 没有规则可以使目标全部'。停止

我已经尝试制作正确的 makefile 一段时间了,但我不断收到错误

“make:*** 没有规则可以使目标‘全部’。停止。”

我有一个主程序:mpasswdsort.c 和 mpasswdsort 使用的 c 文件,它还带有一个标头:list.c 和 list.h

我的生成文件:

CC=gcc
CFLAGS=-Wall -pedantic -ansi
all: mpasswdsort
server: mpasswdsort.o list.o
    $(CC) mpasswdsort.o list.o -o mpasswdsort
mpasswdsort.o: mpasswdsort.cpp
    $(CC) $(CFLAGS) mpasswdsort.cpp
list.o: list.cpp
     $(CC) $(CFLAGS) list.cpp
clean:
    rm -f server client *.o core
Run Code Online (Sandbox Code Playgroud)

我不确定 makefile 是否错误或者 makefile 是否不应该是 .txt 文件。

makefile

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