我有一个Java项目,带有用于REST服务的嵌入式jetty服务器和jersey库.我正在使用Intellij来运行项目及其工作.问题是当我尝试执行生成的jar文件时.
所以我编写了一个在build.gradle文件中生成jar文件的任务.以下是build.gradle中的任务
task fatJar(type: Jar) {
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': 1.0
attributes 'Main-Class': 'EmbeddedJetty.EmbeddedJettyMain'
}
}
Run Code Online (Sandbox Code Playgroud)
运行以下命令时会生成jar文件
gradle clean build fatJar
Run Code Online (Sandbox Code Playgroud)
当我尝试使用该命令生成的jar文件时,我面临以下错误
java -jar projectname.rar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:284)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:238)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:273)
at java.util.jar.JarVerifier.update(JarVerifier.java:228) …Run Code Online (Sandbox Code Playgroud) C#和其他语言通常有空条件?.
A?.B?.Do($C);
Run Code Online (Sandbox Code Playgroud)
当 A 或 B 为空时不会出错。我如何在 powershell 中实现类似的功能,有什么更好的方法可以做到:
if ($A) {
if ($B) {
$A.B.Do($C);
}
}
Run Code Online (Sandbox Code Playgroud) 遗憾的是,我不能使用像Long.Nan这样的表达式,因为字符串实际上是来自不同C模块的返回值.是否有一个字符串我可以传递给parseLong()来返回一个NaN?
我对 qpid-proton-c 和 qpid-cpp 之间的区别感到困惑。有人可以启发我吗?
I have a CI server dumping several application jars and their various dependencies in a single folder. I'm trying to then run a jmeter test with all the jars in jmeter's classpath.
I can set jmeter's user.classpath property to a (semi-)colon separated list of individual jars, but using a wild card doesn't seem to be supported. Is there a way I can add the entire folder worth of jars to jmeter's classpath?
我正在尝试使用一些 Python 代码下载我已经上传到 S3 的一些文件,但是我在尝试使用严格的策略时感到头疼。
我可以列出存储桶中的所有文件,但是当我尝试使用我认为正确的策略下载它们时,我得到 botocore.exceptions.ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden
然后,当我尝试添加适用于 2 个不同存储桶的不同策略时,我添加了存储桶名称的一部分,然后是星号,出于某种原因,完全相同的事情起作用了。
那么有人可以告诉我为什么会发生这种情况吗?
例如,这就像一个魅力:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1499955913000",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": "arn:aws:s3:::THE-BEGINING-OF-THE-NAME*"
}
]
}
Run Code Online (Sandbox Code Playgroud)
但这不会:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1499955913000",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": "arn:aws:s3:::THE-EXACT-COMPLETE-FULL-NAME"
}
]
}
Run Code Online (Sandbox Code Playgroud)
如果相关,我可以为下载添加 python 代码,但是这个问题似乎足够长,代码非常简单
我有一个依赖于的自定义任务installDist- 不仅用于执行,还用于installDist输出:
project.task('run', type: JavaExec, dependsOn: 'installDist', overwrite: true) {
def libdir = new File("$project.tasks.installDist.destinationDir/lib")
...
Run Code Online (Sandbox Code Playgroud)
碰巧当第一次运行时,由于Gradle的工作方式,libdir它不会捕获目标目录installDist.由于我需要libdir用于我的任务,我如何等待installDist完成,然后运行我的任务?
我知道我可以installDist在我的任务之前明确地运行,但我想要在完成之后运行我的任务clean.
我正在尝试使用管道脚本中的作业参数,使用模板文档遵循参数化管道.
我的剧本:
node {
// Display the parameter value of the parameter name "myparam"
println myparam
sh "echo '${myparam}'"
}
Run Code Online (Sandbox Code Playgroud)
但詹金斯找不到我的参数:
groovy.lang.MissingPropertyException: No such property: myparam for class: WorkflowScript
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:458)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.getProperty(DefaultInvoker.java:33)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.run(WorkflowScript:3)
at ___cps.transform___(Native Method)
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
詹金斯版本:2.8
我的全职xml看起来像这样:
<flow-definition plugin="workflow-job@2.2">
<actions />
<description />
<keepDependencies>false</keepDependencies>
<properties>
<com.synopsys.arc.jenkinsci.plugins.jobrestrictions.jobs.JobRestrictionProperty plugin="job-restrictions@0.4" />
<hudson.model.ParametersDefinitionProperty>
<parameterDefinitions>
<hudson.model.StringParameterDefinition>
<name>myparam</name>
<description>bar</description>
<defaultValue>foo</defaultValue>
</hudson.model.StringParameterDefinition>
</parameterDefinitions>
</hudson.model.ParametersDefinitionProperty>
</properties>
<definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="workflow-cps@2.23">
<script>node { //Dislay the parameter value of …Run Code Online (Sandbox Code Playgroud) 我正在使用terraform在aws上创建多个ec2节点:
resource "aws_instance" "myapp" {
count = "${var.count}"
ami = "${data.aws_ami.ubuntu.id}"
instance_type = "m4.large"
vpc_security_group_ids = ["${aws_security_group.myapp-security-group.id}"]
subnet_id = "${var.subnet_id}"
key_name = "${var.key_name}"
iam_instance_profile = "${aws_iam_instance_profile.myapp_instance_profile.id}"
connection {
user = "ubuntu"
private_key = "${file("${var.key_file_path}")}"
}
provisioner "remote-exec" {
inline = [
"sudo apt-get update",
"sudo apt-get upgrade -y",
"sudo apt-get install -f -y openjdk-7-jre-headless git awscli"
]
}
}
Run Code Online (Sandbox Code Playgroud)
当我说count = 4时,某些节点间歇性地失败,并出现apt-get错误,例如:
aws_instance.myapp.1 (remote-exec): E: Unable to locate package awscli
Run Code Online (Sandbox Code Playgroud)
而其他3个节点发现awcli很好。现在,所有节点都是从同一AMI创建的,使用完全相同的配置命令,为什么只有其中一部分会失败?变化可能来自:
哪个更有可能?还有其他可能性吗?
我是否可以使用apt-get“强制”类型标志来使配置更加可重复?
通过脚本自动配置的全部目的是避免节点之间的这种变化:/
给定一个 csv 文件
A,0,0,1,0
B,0,0,1,0
C,0,0,1,0
D,0,0,1,0
E,0,0,1,0
F,0,0,0,1
Run Code Online (Sandbox Code Playgroud)
我想计算每列的总数。有没有比以下更Pythonic或更有效的方法来做到这一点:
import csv
totals = [0]*4
for row in csv.reader(csvfile):
counts = [ int(x) for x in row[-4:] ]
totals = [ sum(x) for x in zip(counts, totals) ]
print(totals)
Run Code Online (Sandbox Code Playgroud) gradle ×2
java ×2
python ×2
amazon-ami ×1
amazon-ec2 ×1
amazon-iam ×1
amazon-s3 ×1
apt-get ×1
boto3 ×1
classpath ×1
csv ×1
jenkins ×1
jmeter ×1
long-integer ×1
nan ×1
powershell ×1
qpid ×1
terraform ×1