我正在为我的maven项目创建测试类,但maven无法导入JUnit,任何想法为什么?
class Recipebook/src/test/java/RecipebookTest.java:
import org.junit.Test;
import org.junit.Before;
/**
*
* @author Mimo
*/
public class RecipebookTest {
@Before
protected void setUp() throws Exception {
}
}
Run Code Online (Sandbox Code Playgroud)
我的pom.xml文件:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fi.muni</groupId>
<artifactId>Recipebook</artifactId>
<version>2.1.0</version>
<packaging>jar</packaging>
<name>Recipebook</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
谢谢
我已经实现了这个扩展方法:
public static IEnumerable<T> DoForEach<T>(this IEnumerable<T> data, Action<T> action)
{
foreach (T value in data)
{
action(value);
yield return value;
}
}
Run Code Online (Sandbox Code Playgroud)
当我做
output.DoForEach<string>(c => Console.WriteLine(c));
Run Code Online (Sandbox Code Playgroud)
没有写入控制台.任何想法为什么这不起作用?谢谢
我无法在QueryDSL中找到任何实现获取计划的方法,我尝试了很多.你能给我任何提示吗?另外,你知道更好的方法来选择要获取哪些字段以及在不同情况下懒散加载哪些字段?我使用批量提取,因此我不能使用JOIN FETCH.
我将我的项目从JBoss AS 7.2迁移到WildFly 8.0,经过一段时间的更新后,我无法弄清楚,如何解决RestEASY和Jackson不兼容问题.
在JBoss AS 7.2中,我使用了RestEASY 3.0.6.Final和Jackson 2.2.1,它们就像一个魅力.但现在,使用WildFly的 Jackson 2.3,存在不兼容性.服务器抛出NoSuchMethodError异常:
13:56:27,049 ERROR [io.undertow.request] (default task-3) UT005023: Exception handling request to /iqpp/applicants/: java.lang.NoSuchMethodError: org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider._configForWriting(Lcom/fasterxml/jackson/databind/ObjectMapper;[Ljava/lang/annotation/Annotation;)Lcom/fasterxml/jackson/jaxrs/json/JsonEndpointConfig;
at org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.writeTo(ResteasyJackson2Provider.java:137) [resteasy-jackson2-provider-3.0.6.Final.jar:]
at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.writeTo(AbstractWriterInterceptorContext.java:129) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.interception.ServerWriterInterceptorContext.writeTo(ServerWriterInterceptorContext.java:62) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:118) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.security.doseta.DigitalSigningInterceptor.aroundWriteTo(DigitalSigningInterceptor.java:143) [resteasy-crypto-3.0.6.Final.jar:]
at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:122) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.aroundWriteTo(GZIPEncodingInterceptor.java:100) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:122) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:99) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispatcher.java:427) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:376) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(SynchronousDispatcher.java:217) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:224) [resteasy-jaxrs-3.0.6.Final.jar:]
at …Run Code Online (Sandbox Code Playgroud) 有没有办法为泛型类实现IEqualityComparer?
我试过了:
public class MyComparer : IEqualityComparer<MyGenericClass>
Run Code Online (Sandbox Code Playgroud)
这是错误的,因为MyGenericClass将3个参数作为泛型,所以下一个
public class MyComparer : IEqualityComparer<MyGenericClass<A, B, C>>
Run Code Online (Sandbox Code Playgroud)
这是错的,因为我不知道类型A,B,C.所以
public class MyComparer<MyGenericClass<A, B, C>> : IEqualityComparer<MyGenericClass<A, B, C>>
Run Code Online (Sandbox Code Playgroud)
是错的.有没有办法实现这个?谢谢
执行特定操作时,我想用文本字段替换按钮.我知道我必须打电话button1.setVisible(false);但我不知道如何在完全相同的地方创建文本字段.我正在使用NetBeans设计器,如果你可以给我一个提示,如何在同一个地方添加2个组件,然后在之间切换,比如在photoshop中切换层之间的东西,如果有可能,那就太棒了.谢谢