简单的流程要求: 在包中找到的所有扩展名List.classjava.util。
这是我正在使用的来源:
Reflections reflections = new Reflections("java.util");
Set<Class<?>> subtypes = reflections.getSubTypesOf(List.class);
Run Code Online (Sandbox Code Playgroud)
很简单,对吧?
它既可以在IntelliJ IDEA中也可以在Eclipse中使用,但是当我通过Maven运行测试时不起作用。我尝试使用所org.reflections.util.ConfigurationBuilder提供的方法添加内容,以添加URL和过滤包名称,但没有运气。
有什么建议么?
我浏览了这篇文章,但无法正常工作:“ 仅当由Maven执行时,使用Reflections谷歌库的单元测试才会失败 ”
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>com.example</groupId>
<artifactId>ohno</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
Sample.java
package com.example.uhoh;
import org.reflections.Reflections;
import java.util.Set;
public class Sample {
@SuppressWarnings ("unchecked")
public static Set<Class<?>> lookup(Class<?> type) {
Reflections reflections = new Reflections("java.util"); …Run Code Online (Sandbox Code Playgroud) 我有一个RSA公钥模数和指数字符串.
我想OpenSSL::PKey::RSA从这两个字符串创建一个.
基本上他们来自:
我将如何在Ruby中执行此操作?最终目标是将其转化为JWT宝石.
我目前在Ruby 2.3.1中,所以这有效:
key = OpenSSL::PKey::RSA.new
key.e = OpenSSL::BN.new(Base64.decode64(e), 2)
key.n = OpenSSL::BN.new(Base64.decode64(n), 2)
Run Code Online (Sandbox Code Playgroud)
但是,它在升级期间不起作用.
注意: 我最初发布这个问题的方式略有不同,不值得更新,因为阅读后我学到了更多.
搜索文档并根据文档中的嵌套元素计算自定义分数.
{
"mappings": {
"book": {
"properties": {
"title": { "type": "string", "index": "not_analyzed" },
"topics": {
"type": "nested",
"properties": {
"title": { "type": "string", "index": "not_analyzed" },
"weight": { "type": "int" }
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
{
"query": {
"function_score": {
"query": {
"term": { "title": "The Magical World of Spittle" }
},
"script_score": {
"script": {
"lang": "painless",
"inline": "int score = 0; for(int i = 0; i < doc['topics'].values.length; i++) …Run Code Online (Sandbox Code Playgroud) 我为所有文档设置了索引:
{
"mappings" {
"book" {
"_source": { "enabled": true },
"properties": [
"title": { "type": "string", "analyzer": "standard", "search_analyzer": "standard" },
"description": { "type": "string", "analyzer": "standard", "search_analyzer": "standard" },
"author": { "type": "string", "analyzer": "standard", "search_analyzer": "standard" }
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
我将其推入名为“ library ” 的索引中。
我想要做的就是执行下列要求进行搜索。假设用户输入了类似“大黄铲”的内容
使用简单的查询可以查找单个搜索:
{
"query": {
"simple_query_string": {
"query": "\"simple yellow shovel\""
}
}
}
Run Code Online (Sandbox Code Playgroud)
如何通过增强执行多重搜索?还是应该在索引字段上使用类似“匹配”的查询?
我有一个AWS DocumentDB设置,我可以使用以下命令通过我的跳转框连接到:
mongo --ssl --host aws-host:27017 --sslCAFile rds-combined-ca-bundle.pem --username my_user --password <insertYourPassword>
Run Code Online (Sandbox Code Playgroud)
我希望能够通过 localhost 连接到它进行一些测试。我无法直接连接,所以我试图从我的跳跃中打开一个隧道:
ssh -i ~/.ssh/my-key user@my_jump -L 27017:aws-host:27017 -N
Run Code Online (Sandbox Code Playgroud)
之后,我尝试了基本的 MongoDB 连接命令:
mongo --ssl --host localhost:27017 --sslCAFile rds-combined-ca-bundle.pem --username my_user --password <insertYourPassword>
Run Code Online (Sandbox Code Playgroud)
我收到一个我理解的错误:
服务器证书与主机名不匹配。主机名:本地主机与 SAN 不匹配
我尝试export http_proxy使用http://my_jump:27017并再次使用上面的命令,但没有成功。
有关如何连接的任何建议或帮助?
使用Serverless和NodeJS,我有一个Slack命令设置如下:
/myCommand doStuff
Run Code Online (Sandbox Code Playgroud)
当我输入时/myCommand doStuff,Slack输出执行此操作:
/myCommand doStuff我想要显示的实际响应的内容就在这里.
我想要做的只是这个:
我想要显示的实际响应的内容就在这里.
没有/myCommand doStuff得到回应.
我该如何防止这种情况发生?
这是实际的命令:
module.exports = () => {
return new Promise(function(fulfill) {
fulfill({
response_type: 'in_channel',
text: 'some testing text
});
});
};
Run Code Online (Sandbox Code Playgroud)
这是处理程序:
module.exports.handler = (event, context, callback) => {
var response = {
statusCode: 200,
body: JSON.stringify(myCommand()),
};
callback(null, response);
};
Run Code Online (Sandbox Code Playgroud) 我下面列出的类 ( ServiceDiscoveryConfiguration) 从未被使用过。即使我删除了@EnableDiscoveryClient以试图完全避免设置,它仍然会尝试连接到 Consul。
唯一对我有用的是完全删除 Consul Maven 依赖:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
如果不通过配置文件和注释设置,我可以做些什么来阻止 Consul 运行单元测试?
我有一个使用 Spring Consul 的应用程序。我设置了一个类来启用这样的发现:
@Profile ("!" + Profiles.UNIT_TEST)
@Configuration
@EnableDiscoveryClient
public class ServiceDiscoveryConfiguration {
}
Run Code Online (Sandbox Code Playgroud)
如果我没记错的话,这应该是禁用 Consul 部分。基本测试类(它abstract在我的所有单元测试之间共享)使用以下注释设置。这就是我认为问题所在。
@SpringBootTest (classes = Service.class)
@WebAppConfiguration
@TestExecutionListeners (...)
@DirtiesContext
@ActiveProfiles (Profiles.UNIT_TEST)
@Test (...)
public abstract class AbstractBootTest extends AbstractTestNGSpringContextTests {
// ...
}
Run Code Online (Sandbox Code Playgroud)
当我执行我的测试时,我得到:
引起:com.ecwid.consul.transport.TransportException:java.net.ConnectException:连接被拒绝
这让我相信配置文件激活不起作用,或者我!在@Profile规范上使用运算符的语法没有做我认为应该做的事情。根执行类本身有基本的注释,包括一个@ComponentScan注释,我知道它有适当的包被扫描。 …
如何在Jacoco涵盖范围中忽略* .1类?
我的POM中包含以下内容:
<execution>
<id>JaCoco Coverage Enforcement</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/coverage-reports/jacoco-unit.exec</dataFile>
<excludes>
<exclude>**/MyClass.**</exclude>
</excludes>
<rules>
...
</rules>
</execution>
Run Code Online (Sandbox Code Playgroud)
但是,我收到以下错误消息:
[警告] com.mypackage.MyClass.1类违反了规则:行覆盖率是0.00,但预期最小值是0.85
更新12/19
这是文件夹结构中的内容:
$ find . -iname 'MyClass*class'
./target/classes/com/mypackage/MyClass$1.class
./target/classes/com/mypackage/MyClass.class
Run Code Online (Sandbox Code Playgroud) 我一直在仔细研究与 kubeadm 相关的链接,尝试更改 Kubernetes 集群证书上的密码。问题是我需要禁用 DES/3DES,这样该命令就会失败:
openssl s_client -connect IP:2379 -cipher "DES:3DES" -tls1_2
Run Code Online (Sandbox Code Playgroud)
到目前为止我浏览过的一些链接(如果我把它们全部列出来,这篇文章会太长):
我希望更改kube-apiserver配置以使用这些标志(在/etc/kubernetes/manifests/kube-apiserver.yaml文件中)会有所帮助,但事实并非如此(请原谅拼写错误,我无法从我必须使用的客户端中复制/粘贴):
...
spec:
containers:
- command:
- kube-apiserver
- ...
- --tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
- --tls-min-version=VersionTLS12
image: k8s.gcr.io/kube-apiserver:v1.18.6
...
Run Code Online (Sandbox Code Playgroud)
/etc/kubernetes/pki我可以按照这些指南手动重新生成所有证书,但我希望坚持使用 Kuberneteskubeadm或其他 Kubernetes 提供的工具来自动处理它。我找不到任何关于手动生成每个文件的文档,这些文件是为完全不熟悉管理的人设置的。
感谢帮助、链接、建议等!不幸的是,在完成此操作之前,我不允许使用集群,甚至不能向人们演示功能。
来自亚马逊的元数据URL提供了大量数据,但滞后于标签信息.我试图结合一堆不同的命令,最终得到了describe-tags CLI命令.问题是,虽然我可以轻松地获得实例ID和区域,但我无法在不将凭据丢弃到框中的情况下获取标记的值.
我收到以下错误:
无法找到凭据.您可以通过运行"aws configure"来配置凭据.
最终执行的基本命令是:
aws ec2 describe-tags --region us-east-1 --filters "Name=resource-id,Values=SOME_ID"
Run Code Online (Sandbox Code Playgroud)
我遵循的流程如下:
有什么办法绕过凭证问题? 我认为本地机器可以访问自己的标签元数据而无需登录,但似乎并非如此.
如果无法绕过它,是否有任何建议将数据传递给虚拟机而无需坐下来等待它启动?
我真的不想写一个等待EC2完成旋转,SSH进入然后自己传递关键数据的进程.数据会即时更改,并且可以在我启动的实例之间进行更改,以便处理各种事件.
amazon-ec2 ×1
aws-cli ×1
consul ×1
jacoco ×1
java ×1
kubeadm ×1
kubernetes ×1
maven ×1
maven-3 ×1
node.js ×1
reflections ×1
rsa ×1
ruby ×1
slack ×1
slack-api ×1
spring ×1
spring-boot ×1
ssh-tunnel ×1