我最近发现了 Java记录,了解它们的存在和用途真是太神奇了。
然而,我开始怀疑它们是否本质上只是幕后的类。
这是否意味着在编译过程中,它们会被转换为具有最终私有字段、公共构造函数和必要的 getter 的显式类?
不幸的是,即使是 IntelliJ 的最新早期访问版本通常也不支持 Java 的早期访问版本。
\n例如,我尝试将Intellij 2022.1.1 Preview (Ultimate Edition)与基于早期访问Java 19的Project Loom实验版本一起使用。安装 JDK 通常适用于 IntelliJ。
\n但现在我想使用 Loom 特定的功能。当我调用这个实验性 Java 19 中的新方法时,我从编译器中收到以下错误:
\n\n\njava: newVirtualThreadPerTaskExecutor() 是预览 API,默认情况下处于禁用状态。
\n(使用 --enable-preview 启用预览 API)
\n
我的第一个想法是在文件 > 项目结构 > 项目设置 > 项目和\xe2\x80\xa6 模块面板上设置语言级别字段。但显然 IntelliJ 没有为这个早期访问 Java 19 的(预览)模式提供任何菜单项。
\n有没有办法让 IntelliJ 使用新的预览 API?
\n我知道错误消息的建议--enable-preview是在某处应用的标志。但我不知道在哪里。
我有以下代码:
@Component
public class Wrapper
{
@Resource
private List<Strategy> strategies;
public String getName(String id)
{
// the revelant part of this statement is that I would like to iterate over "strategies"
return strategies.stream()
.filter(strategy -> strategy.isApplicable(id))
.findFirst().get().getAmount(id);
}
}
Run Code Online (Sandbox Code Playgroud)
@Component
public class StrategyA implements Strategy{...}
@Component
public class StrategyB implements Strategy{...}
Run Code Online (Sandbox Code Playgroud)
我想用Mockito为它创建一个测试.我写的测试如下:
@InjectMocks
private Wrapper testedObject = new Wrapper ();
// I was hoping that this list will contain both strategies: strategyA and strategyB
@Mock
private List<Strategy> strategies;
@Mock
StrategyA …Run Code Online (Sandbox Code Playgroud) 我正在使用 Java 19。我尝试使用新引入的虚拟线程,如下所示:
public static void main(String[] args) {
System.out.println("Started with virutal threads");
try (ExecutorService virtualService = Executors.newVirtualThreadPerTaskExecutor()) {
virtualService.submit(() -> System.out.println("[" + Thread.currentThread().getName() + "] virtual task 1"));
virtualService.submit(() -> System.out.println("[" + Thread.currentThread().getName() + "] virtual task 2"));
}
System.out.println("Finished");
}
Run Code Online (Sandbox Code Playgroud)
该程序的输出是:
Started with virutal threads
[] virtual task 2
[] virtual task 1
Finished
Run Code Online (Sandbox Code Playgroud)
为什么 Thread.currentThread().getName() 没有任何名称?
后续问题:如何识别彼此之间的虚拟线程?(如何识别它们)所以输出看起来像
[thread-1] virtual task 2
[thread-0] virtual task 1
Run Code Online (Sandbox Code Playgroud) 我正在使用 kubectl 来检索 pod 列表:
kubectl get pods --selector=artifact=boot-example -n my-sandbox
Run Code Online (Sandbox Code Playgroud)
我得到的结果是:
NAME READY STATUS RESTARTS AGE
boot-example-757c4c6d9c-kk7mg 0/1 Running 0 77m
boot-example-7dd6cd8d49-d46xs 1/1 Running 0 84m
boot-example-7dd6cd8d49-sktf8 1/1 Running 0 88m
Run Code Online (Sandbox Code Playgroud)
我只想得到那些“准备好”的豆荚(通过了readinessProbe)。是否有任何 kubectl 命令只返回“就绪”pods?如果不是 kubectl 命令,那么也许是其他方式?
我在 Azure DevOps 中有 3 个管道,每个分支都有,代码位于 GitHub 上。
每当我执行任何拉取请求时,我的 3 个管道都会被触发。我怎样才能避免这种情况?
该消息显示“公关自动化”
我的 3 个管道使用独立的分支:
开发管道
trigger:
branches:
include: [develop]
paths:
include:
- backend/*
Run Code Online (Sandbox Code Playgroud)
暂存管道
trigger:
branches:
include: [staging]
paths:
include:
- backend/*
Run Code Online (Sandbox Code Playgroud)
生产流水线
trigger:
branches:
include: [master]
paths:
include:
- backend/*
Run Code Online (Sandbox Code Playgroud) 我正在使用 Azure Cosmos DB。我在 Azure 门户中创建了一个简单的触发器,如下所示:
var context = getContext();
var request = context.getRequest();
// item to be created in the current operation
var itemToCreate = request.getBody();
itemToCreate["address"] = "test";
// update the item that will be created
request.setBody(itemToCreate);
Run Code Online (Sandbox Code Playgroud)
不幸的是,当我插入新文档时没有触发这个触发器。我还尝试将“触发器类型”设置为“发布”。我错过了什么吗?
我正在尝试使用 azurerm_resource_group_template_deployment
resource "azurerm_resource_group_template_deployment" "my-arm-template" {
parameters_content = {
location = azurerm_resource_group.my_rg.location
}
name = "my_name"
...
}
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
Inappropriate value for attribute "parameters_content": string required.
Run Code Online (Sandbox Code Playgroud)
我应该如何定义 parameters_content 部分?
我在版本中使用 kubernetes dasboard:v1.10.1
当我转到“角色”选项卡时,我可以看到 ClusterRoles 和角色的列表。
我想从列表中查看有关特定角色的更多详细信息,但没有看到任何“详细信息”按钮。我想在仪表板小部件中甚至以 yaml 格式查看有关角色的信息。我是否遗漏了什么或无法通过仪表板实现?
java ×5
kubernetes ×2
azure ×1
azure-devops ×1
azureportal ×1
dashboard ×1
git ×1
github ×1
java-19 ×1
java-record ×1
junit ×1
kubectl ×1
mockito ×1
rbac ×1
record ×1
spring ×1
terraform ×1