小编Fer*_*big的帖子

在jenkins中运行maven/surefire构建时间歇性的NoClassDefFoundError

我们正在Jenkins上构建一个大型的多模块Maven项目,包括运行大量的单元测试.

每隔几个构建版本构建失败NoClassDefFoundError on RunListener- 它位于单元jar中.从下面的日志中可以看出 - JUnit包含在类路径中.

该错误似乎完全随机出现.

日志

Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project taboola-svc: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed: A required class was missing while executing org.apache.maven.plugins:maven-surefire-plugin:2.17:test: org/junit/runner/notification/RunListener
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.maven.plugins:maven-surefire-plugin:2.17
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/builder/.m2/repository/org/apache/maven/plugins/maven-surefire-plugin/2.17/maven-surefire-plugin-2.17.jar
[ERROR] urls[1] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-junit47/2.17/surefire-junit47-2.17.jar
[ERROR] urls[2] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-junit48/2.17/common-junit48-2.17.jar
[ERROR] urls[3] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-junit4/2.17/common-junit4-2.17.jar
[ERROR] urls[4] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-junit3/2.17/common-junit3-2.17.jar
[ERROR] urls[5] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-grouper/2.17/surefire-grouper-2.17.jar
[ERROR] urls[6] = …
Run Code Online (Sandbox Code Playgroud)

java junit surefire maven jenkins

15
推荐指数
1
解决办法
9476
查看次数

EnumSet认为我的枚举不是枚举

在我的生产代码中,我在枚举的构造函数中构造一个EnumSet,但它无法检测到我的类是一个实际的枚举.这个错误打破了我的真实生产代码

为了测试目的,我编写了下面的类,但即使使用这个小例子,它仍然无法识别枚举.我如何将我的类标记为EnumSet知道它是枚举的方式的枚举?

简单的源代码:

package test;
import java.util.*; // Set, EnumSet, Arrays
public enum Alphabet {
    A, 
    B(A), 
    C(A, B), 
    D(A, B, C),
    // You get the point
    ;
    Set<Alphabet> prevLetters;

    Alphabet() {
        prevLetters = EnumSet.noneOf(Alphabet.class); // <- EnumSet here
    }

    Alphabet(Alphabet... prev) {
        this();
        prevLetters.addAll(Arrays.asList(prev));
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(Alphabet.values()));
    }

}
Run Code Online (Sandbox Code Playgroud)

例外:

Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.ClassCastException: class test.Alphabet not an enum
    at java.util.EnumSet.noneOf(EnumSet.java:112)
    at test.Alphabet.<init>(Test.java:13)
    at test.Alphabet.<clinit>(Test.java:4)
Run Code Online (Sandbox Code Playgroud)

java enums

5
推荐指数
0
解决办法
88
查看次数

Vue-google-map自动完成双向绑定无法正常工作

我正在使用vue-google-maps,我已经实现了插件,它运行完美,但是有一个小问题(或者我可能无法正确执行).当我实现自动完成功能时,它以一种方式工作.我输入地址,地图将我指向所选位置,但是当我拖动指针时,它不会更新搜索字段中的地址. 我正在使用Vuejs 2vue-google-maps

这就是我在做的事情:

<template>
    <div>
        <label>
            AutoComplete
            <GmapAutocomplete :position.sync="markers[0].position" @keyup.enter="usePlace" @place_changed="setPlace">
            </GmapAutocomplete>
            <button @click="usePlace">Add</button>
        </label>
        <br/>

        <gmap-map
            :center="center"
            :zoom="7"
            map-type-id="terrain"
            style="width: 100%; height: 500px"
        >
            <gmap-marker
                @dragend="updateMaker" 
                :key="index"
                v-for="(m, index) in markers"
                :position="m.position"
                :clickable="true"
                :draggable="true"
                @click="center=m.position"
            ></gmap-marker>

        </gmap-map>

    </div>
</template>

<script>

    export default {
        data() {
            return {
                center: {lat: 10.0, lng: 10.0},
                markers: [{
                    position: {lat: 11.0, lng: 11.0}
                }],
                place: null,
            }
        },
        description: 'Autocomplete Example (#164)',
        methods: {
            setPlace(place) {
                this.place = …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps google-maps-markers vue.js vuejs2

5
推荐指数
1
解决办法
1010
查看次数

Netty没有写

当尝试使用netty写入时,写入的数据永远不会在远程端结束,并通过Wireshark确认.

我试过了:

//Directly using writeAndFlush
channel.writeAndFlush(new Packet());

//Manually flushing
channel.write(new Packet());
channel.flush();

// Even sending bytes won't work:
channel.writeAndFlush(new byte[]{1,2,3});
Run Code Online (Sandbox Code Playgroud)

当我把它包起来时没有被捕获 try{...}catch(Throwable e){e.printStackTrace();}

我该怎么做来调试这个问题?

java netty

1
推荐指数
1
解决办法
724
查看次数

Java程序我想用HTML运行

我有一个简单的Hello.java类,我想把它放在一个网站上.

 public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
Run Code Online (Sandbox Code Playgroud)

我试着这样做

jar cf Hello.jar Hello.java
Run Code Online (Sandbox Code Playgroud)

然后在网站上尝试让它运行我放

<h2> Hello Test </h2>
<APPLET 
   CODE="Hello.class"
   WIDTH="50%" HEIGHT="50"
   ARCHIVE = "Hello.jar"
> This example uses a Hello.jar applet.
</APPLET>
Run Code Online (Sandbox Code Playgroud)

不用说它不起作用.

html java applet jar

0
推荐指数
1
解决办法
131
查看次数