我只发现了如何在旧版本的IDEA中删除项目,但仍然没有看到我的IDEA 14中的按钮.Jetbrains的人是否实现了这个功能,还是我还要在文件浏览器中手动删除我的项目文件夹?
我正在经历Intellij IDEA 2016.3的奇怪行为.在运行测试foo时得到方法的类和方法的JUnit java.lang.Exception: No tests found matching Method foo测试.我mvn test成功后,然后在执行mvn命令后立即运行单元测试,它突然变为绿色.似乎IDEA不会自动编译.我怎样才能解决这个问题?
PS升级至v.2016.3后,未更改任何设置
如何格式化return语句,使其也与参数说明对齐(参见下图)

我希望return声明的第二行至少与第一行对齐,在这种特殊情况下,该单词needed应与该单词对齐Some.我尝试了所有设置,Settings -> Editor -> Code Style -> Java -> Tab "JavaDoc"但没有找到任何设置return.这是所需输出的片段:
/**
* Add 2 to x and multiplies the result with y.
*
* @param x X param.
* @param y Y param
*
* @return Some very long return description of the return statement even if it sometimes does not make sense but is
* needed to show the purpose of my question. …Run Code Online (Sandbox Code Playgroud) 我有以下结构的 JSON 文件:
[
{
"key1":"value1",
"key2":"value2",
"key3":"value3",
"key4":"value4",
},
{
"key1":"value1",
"key2":"value2",
"key3":"value3",
"key4":"value4",
}
]
Run Code Online (Sandbox Code Playgroud)
我通过 HTTP 调用得到了它。我尝试将此 JSON 解析为 flutter 对象。因此我写了一个类:
class Foo {
List<Model> modelsAsJson;
Foo({this.modelsAsJson});
Foo.fromJson(List<dynamic> jsonData) {
modelsAsJson = jsonData.map((listItem) => Model.fromJson(listItem)).toList();
Foo(modelsAsJson: modelsAsJson);
}
}
Run Code Online (Sandbox Code Playgroud)
我还为 编写了另一个类Model:
class Model {
String value1;
String value2;
String value3;
String value4;
Model({this.value1, this.value2, this.value3, this.value4});
Model.fromJson(Map<String, dynamic> json) {
Model(value1: json['key1'], value2: json['key2'], value3: json['key3'], value4: json['key4'],);
}
Map<String, dynamic> toJson() => {
'key1': …Run Code Online (Sandbox Code Playgroud) 在我的 web 服务器应用程序中,我有一个方法,它修改一个 xml 文档,看起来类似于:
@POST
@Path("somePath")
@Consumes({"application/xml", "application/zip"})
public Response modifyXml() {
//some processing
}
Run Code Online (Sandbox Code Playgroud)
使用的 zip 存档包含需要修改的 xml 文件和一些其他文件。如何区分消耗的 xml 文件和方法内的存档,以及我应该使用哪种方法参数来表示这个消耗的资源?
在课堂上,我们必须使用Dot Product编写一个小代码来查找两个数组的总和(数组a和数组b).我编写了我的代码,但是当我运行它时它没有给我答案.我的教授说我的循环是错误的,但我认为不是.是否i<a.length在for循环参数中说不允许的部分?因为即使我把它设置为n,它仍然不会给我总和.
这是我的代码:
public class arrayExample {
public static void main (String [] args) {
int[] a = {1,2,2,1};
int[] b = {1,2,2,1};
int n = a.length;
int sum = 0;
for (int i = 0; i < a.length; i++) {
sum += a[n] * b[n];
}
System.out.println(sum);
}
}
Run Code Online (Sandbox Code Playgroud) 如何使用 jimfs 设置文件的上次修改日期?我有。像这样:
final FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix());
Path rootPath = Files.createDirectories(fileSystem.getPath("root/path/to/directory"));
Path filePath = rootPath.resolve("test1.pdf");
Path anotherFilePath = rootPath.resolve("test2.pdf");
Run Code Online (Sandbox Code Playgroud)
创建完这些东西后,我创建了一个目录迭代器,如:
try (final DirectoryStream<Path> dirStream = Files.newDirectoryStream(rootPath, "*.pdf")) {
final Iterator<Path> pathIterator = dirStream.iterator();
}
Run Code Online (Sandbox Code Playgroud)
之后,我遍历文件并读取最后修改的文件,然后返回:
Path resolveLastModified(Iterator<Path> dirStreamIterator){
long lastModified = Long.MIN_VALUE;
File lastModifiedFile = null;
while (dirStreamIterator.hasNext()) {
File file = new File(dirStreamIterator.next().toString());
final long actualLastModified = file.lastModified();
if (actualLastModified > lastModified) {
lastModifiedFile = file;
lastModified = actualLastModified;
}
}
return lastModifiedFile.toPath();
}
Run Code Online (Sandbox Code Playgroud)
问题是文件“test1.pdf”和“test2.pdf”的lastModified都为“0”,所以我实际上无法真正测试行为,因为该方法总是返回目录中的第一个文件。我试着做:
File file = …Run Code Online (Sandbox Code Playgroud) 如何使用Mockito模拟枚举以进行测试?给出枚举的这个示例:
public enum TestEnum {
YES,
NO
}
Run Code Online (Sandbox Code Playgroud)
这个用于使用枚举的方法:
public static boolean WorkTheEnum(TestEnum theEnum) {
switch (theEnum) {
case YES:
return true;
case NO:
return false;
default:
// throws an exception here
}
}
Run Code Online (Sandbox Code Playgroud)
如何模拟枚举以达到开关循环的默认分支?这个答案说Mockito不能模仿枚举,但答案也是在一年多前提供的.我可以同时嘲笑enum还是让我让分支保持未经测试?其他Mocking框架不能使用.
每次我克隆一个仓库时,我都必须手动设置 Maven 主目录,File->Settings->Build, Execution, Deployment->Build Tools-> Maven-> Maven home directory这非常烦人。我搜索了 jetbrains 论坛,发现只有一个选项可以为未来的项目配置 IDE,但在某些情况下这永远不可能成为事实。将存储库克隆到创意项目中并不是创建新项目,因此不会触发全局设置。我怎样才能做到这一点?顺便说一句,它不仅适用于 Maven 主目录,还适用于代码样式设置和许多其他设置 - 请参阅此处
我知道已经有至少两个相同的问题,但我仍然无法弄清楚为什么我得到例外.我需要对这个方法进行单元测试:
void setEyelet(final PdfWriter printPdf, final float posX, final float posY) {
InputStream is = WithDefinitions.class.getResourceAsStream(RES_EYELET); //RES_EYELET is a pdf.
PdfContentByte canvas = printPdf.getDirectContent();
PdfReader reader = new PdfReader(is);
PdfImportedPage page = printPdf.getImportedPage(reader, 1);
canvas.addTemplate(page, posX, posY);
reader.close();
}
Run Code Online (Sandbox Code Playgroud)
并验证
canvas.addTemplate(page, posX, posY);
Run Code Online (Sandbox Code Playgroud)
被称为.
此方法嵌套在另一个方法中:
void computeEyelets(final PdfWriter printPdf) {
float lineLeft = borderLeft + EYELET_MARGIN;
float lineRight = printPdfWidth - borderRight - EYELET_MARGIN - EYELET_SIZE;
float lineTop = printPdfHeight - borderTop - EYELET_MARGIN - EYELET_SIZE;
float lineBottom = borderBottom …Run Code Online (Sandbox Code Playgroud)