我正面临 JUnit jar 兼容性问题。最初,当我创建我的 JUnit 类时,下面是主要的 jar 版本。
springframework.boot.version 1.3.0.RELEASE
Mock - mockito-core-1.10.19.jar
Power mockito - powermock-module-junit4-1.6.4.jar
powermock-api-mockito-1.6.4.jar
Run Code Online (Sandbox Code Playgroud)
现在我们已经将 spring boot 版本升级到 2.0.0.RELEASE 并且 maven build 正在下降并出现以下错误
Tests in error:
initializationError(com.amit.Test.TestStudent): org/mockito/cglib/proxy/Enhancer
testAddress(com.amit.test.TestAddressProcess): Could not initialize plugin: interface org.mockito.plugins.MockMaker
Run Code Online (Sandbox Code Playgroud)
我尝试了以下答案并将 powermock-api-mockito 更改为 powermock-api-mockito2 无法初始化插件:接口 org.mockito.plugins.MockMaker
但低于错误
testAddress((com.amit.test.TestAddressProcess): Invoking the beforeTestMethod method on PowerMock test listener org.powermock.api.extension.listener.AnnotationEnabler@22277482 failed.
Run Code Online (Sandbox Code Playgroud)
更新的版本是
springframework.boot.version 2.0.0.RELEASE
Mock - mockito-core-2.15.0.jar
Power mockito - powermock-module-junit4-2.0.0.jar
powermock-api-mockito-2.0.0.jar
Run Code Online (Sandbox Code Playgroud)
如果其他人遇到与 jar 版本相同的问题,请提供帮助
完整的堆栈跟踪
java.lang.RuntimeException: Invoking the beforeTestMethod method on PowerMock test …Run Code Online (Sandbox Code Playgroud) 从jenkins工作为我的一个项目运行声纳时我面临着问题,
"无法执行SonarQube分析:无法执行超时阈值为1200000毫秒的Findbugs:TimeoutException - > [Help 1]"
我试图谷歌寻求帮助,但我发现只有解决方案. "您可以增加超时:设置>常规设置> Java> Findbugs> sonar.findbugs.timeout"
在我的办公室jenkins作为服务安装,我无法找到上述提到的路径,任何人都会请详细说明这个问题的可能原因.什么是解决方案,如果解决方案如上所述,那么请指导我在哪里可以找到路径或请让我知道,如果我需要更新任何配置文件.
public class Base {
private Base instance;
private Base() {
}
public static class BaseHelper {
Base instance = new Base();
}
}
Run Code Online (Sandbox Code Playgroud)
在上面的例子中,我在基类中有一个无参构造函数.现在我列出这个类的构造函数,如下所示:
Constructor<?>[] constructors = Base.class.getDeclaredConstructors();
System.out.println(constructors);
Run Code Online (Sandbox Code Playgroud)
运行此代码时,我得到以下输出:
[private com.Base(), com.Base(com.Base)]
Run Code Online (Sandbox Code Playgroud)
这告诉我有两个构造函数:
为什么是这样?
有一个疑问是等于在Array List中工作的方法,下面代码剪断它打印为true.
ArrayList<String> s = new ArrayList<String>();
ArrayList<Integer> s1 = new ArrayList<Integer>();
System.out.println(s1.equals(s));
Run Code Online (Sandbox Code Playgroud)
有人知道为什么它会给出真正的答案.
在测验中,我发现了一个问题,我需要从下面的程序中计算出来
public static void main(String[] args) {
short x = 0;
int b = 08;
x +=b;
System.out.println("" + b + x );
}
Run Code Online (Sandbox Code Playgroud)
它给出了编译错误
int b = 08;
Run Code Online (Sandbox Code Playgroud)
因为它是八进制值,所以我尝试了一些不同的值
int b = 07 // working fine (decimal of same is 7)
int b = 08 // (Decimal value 8) // Compilation error
int b = 09 // (Decimal value 9) // Compilation error
int b = 010 // (Decimal value 8) // No Compilation error
Run Code Online (Sandbox Code Playgroud)
由于08和010具有相同的十进制数,因此08为什么会出现编译错误.
下面是我用来读取gz文件的代码
import json
import boto3
from io import BytesIO
import gzip
def lambda_handler(event, context):
try:
s3 = boto3.resource('s3')
key='test.gz'
obj = s3.Object('athenaamit',key)
n = obj.get()['Body'].read()
#print(n)
gzip = BytesIO(n)
gzipfile = gzip.GzipFile(fileobj=gzip)
content = gzipfile.read()
print(content)
return 'dddd'
Run Code Online (Sandbox Code Playgroud)
except Exception as e: print(e) raise e 但是我遇到了以下错误
"errorMessage": "'_io.BytesIO' object has no attribute 'GzipFile'",
"stackTrace": [
" File \"/var/task/lambda_function.py\", line 20, in lambda_handler\n raise e\n",
" File \"/var/task/lambda_function.py\", line 14, in lambda_handler\n gzipfile = gzip.GzipFile(fileobj=gzip)\n"
Run Code Online (Sandbox Code Playgroud)
蟒蛇版本-3.7
我还尝试实现以下建议 /sf/ask/2295638621/ gzipfile-and-write-to-gzipfile
但它也不适合我,请建议我如何读取文件内容
我在poc工作,我需要创建数据帧,然后将其保存为ctrl一个分隔文件.我创建中间结果的查询如下
val grouped = results.groupBy("club_data","student_id_add","student_id").agg(sum(results("amount").cast(IntegerType)).as("amount"),count("amount").as("cnt")).filter((length(trim($"student_id")) > 1) && ($"student_id").isNotNull)
Run Code Online (Sandbox Code Playgroud)
将结果保存在文本文件中
grouped.select($"club_data", $"student_id_add", $"amount",$"cnt").rdd.saveAsTextFile("/amit/spark/output4/")
Run Code Online (Sandbox Code Playgroud)
输出:
[amit,DI^A356035,581,1]
Run Code Online (Sandbox Code Playgroud)
它以逗号分隔保存数据,但我需要将其保存为ctrl-A单独的I尝试选项("分隔符","\ u0001")但似乎不受dataframe/rdd支持.
有什么功能有帮助吗?
java ×4
amazon-s3 ×1
apache-spark ×1
aws-sdk ×1
boto3 ×1
dataframe ×1
findbugs ×1
junit ×1
mockito ×1
powermockito ×1
python ×1
reflection ×1
scala ×1
sonarqube ×1
spring-boot ×1