我已经搜索了谷歌并在StackOverflow上查看了答案,但似乎无法解决这个问题.我最近加入了这个项目并为POM添加了一些东西.作为Maven的相对新手,我没有理解这个问题,我所看到的反应并没有得到澄清.我怀疑这是Groovy添加到项目中.我想使用Groovy和Spock进行测试(并且希望最终也能用于测试).
[INFO] Using Groovy-Eclipse compiler to compile both Java and Groovy files
[FATAL ERROR] org.apache.maven.plugin.CompilerMojo#execute() caused a linkage error (java.lang.NoSuchMethodError) and may be out-of-date. Check the realms:
[FATAL ERROR] Plugin realm = app0.child-container[org.apache.maven.plugins:maven-compiler-plugin:2.0.2]
urls[0] = file:/C:/Users/bill.turner/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/2.0.2/maven-compiler-plugin-2.0.2.jar
urls[1] = file:/C:/Users/bill.turner/.m2/repository/org/codehaus/groovy/groovy-eclipse-compiler/2.7.0-01/groovy-eclipse-compiler-2.7.0-01.jar
urls[2] = file:/C:/Users/bill.turner/.m2/repository/org/codehaus/groovy/groovy-eclipse-batch/2.0.4-02/groovy-eclipse-batch-2.0.4-02.jar
urls[3] = file:/C:/Users/bill.turner/.m2/repository/org/codehaus/plexus/plexus-compiler-api/1.5.3/plexus-compiler-api-1.5.3.jar
urls[4] = file:/C:/Users/bill.turner/.m2/repository/org/codehaus/plexus/plexus-utils/1.0.4/plexus-utils-1.0.4.jar
urls[5] = file:/C:/Users/bill.turner/.m2/repository/org/codehaus/plexus/plexus-compiler-manager/1.5.3/plexus-compiler-manager-1.5.3.jar
urls[6] = file:/C:/Users/bill.turner/.m2/repository/org/codehaus/plexus/plexus-compiler-javac/1.5.3/plexus-compiler-javac-1.5.3.jar
[FATAL ERROR] Container realm = plexus.core
urls[0] = file:/C:/Users/bill.turner/apache-maven-2.2.1/lib/maven-2.2.1-uber.jar
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] org.codehaus.plexus.compiler.CompilerConfiguration.getDebugLevel()Ljava/lang/String;
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.NoSuchMethodError: org.codehaus.plexus.compiler.CompilerConfiguration.getDebugLevel()Ljava/lang/String;
at org.codehaus.groovy.eclipse.compiler.GroovyEclipseCompiler.createCommandLine(GroovyEclipseCompiler.java:343) …Run Code Online (Sandbox Code Playgroud) 在 Mac 上运行 vscode。我更新了 Mac bash 版本,正如您所看到的,内置的 vscode 终端显示的 bash 版本与 Mac 终端的版本相同。当我获取 .bash_profile 时,我invalid shell option name在 vscode 终端中收到错误。是什么原因造成的?
FWIW - 终端 > 集成 > Shell: Osx 设置为bin/bash,如果这不明显的话。而且,我的 SHELL 变量是相同的。
我有一个有三个名为@Resource成员的类,如下所示:
@Resource(name = "contactsPaginationRequestValidator")
private PaginationRequestValidator paginationRequestValidator;
@Resource(name = "integerMaxPaginationRequestValidator")
private PaginationRequestValidator integerMaxPaginationRequestValidator;
@Resource(name = "contactsSearchResultPaginationRequestValidator")
private PaginationRequestValidator contactsSearchResultPaginationRequestValidator;
Run Code Online (Sandbox Code Playgroud)
从1.8.5升级到Mockito 1.9.5后,测试开始失败.测试套件只模拟了一次PaginationRequestValidator,如下所示:
@Mock
private PaginationRequestValidator mockPaginationRequestValidator;
Run Code Online (Sandbox Code Playgroud)
这导致三个实例中只有三个被注入,因为以下sysout明确说明:
paginationRequestValidator (contactsPaginationRequestValidator) is null
integerMaxPaginationRequestValidator (integerMaxPaginationRequestValidator) is null
contactsSearchResultPaginationRequestValidator (contactsSearchResultPaginationRequestValidator) is mockPaginationRequestValidator
Run Code Online (Sandbox Code Playgroud)
显然,两个版本之间的行为发生了变化.我假设旧版本将模拟注入所有三个字段 - 这对我来说仍然是一个可接受的解决方案.
作为我的聪明人,我想我可以通过提供与资源相关联的名称来通过测试,如下所示:
@Mock(name = "contactsPaginationRequestValidator")
private PaginationRequestValidator mockPaginationRequestValidator;
Run Code Online (Sandbox Code Playgroud)
这导致了类似但略有不同的结果.如上所述,第三个字段,而不是预期的目标字段被嘲笑,但它被模拟了@Mock中提供的名称.查看sysout:
paginationRequestValidator (contactsPaginationRequestValidator) is null
integerMaxPaginationRequestValidator (integerMaxPaginationRequestValidator) is null
contactsSearchResultPaginationRequestValidator (contactsSearchResultPaginationRequestValidator) is contactsPaginationRequestValidator
Run Code Online (Sandbox Code Playgroud)
这是完全出乎意料的行为.然而,还有更多.当我为第二个字段添加一个类似的模拟时,所有字段都按预期模拟了:
@Mock(name = "contactsPaginationRequestValidator")
private PaginationRequestValidator mockPaginationRequestValidator;
@Mock(name = "integerMaxPaginationRequestValidator")
private PaginationRequestValidator mockIntegerMaxPaginationRequestValidator;
Run Code Online (Sandbox Code Playgroud)
SYSOUT:
paginationRequestValidator (contactsPaginationRequestValidator) is contactsPaginationRequestValidator
integerMaxPaginationRequestValidator …Run Code Online (Sandbox Code Playgroud) 在1.8控制台中运行以下命令:
def accessories = null
final int prime = 31;
int result = 1;
result = prime
* result
+ ((accessories == null) ? 0 : accessories
.hashCode());
Run Code Online (Sandbox Code Playgroud)
我得到一个编译错误说明:
意外的令牌:*在第5行,列:13
然而,当我将"*结果"移动到前一行时,它会编译并运行得干净利落.我搜索过试图找到一个解释,但到目前为止没有运气.谁能解释一下?
def accessories = null
final int prime = 31;
int result = 1;
result = prime * result
+ ((accessories == null) ? 0 : accessories
.hashCode());
Run Code Online (Sandbox Code Playgroud) 我收到以下警告,这似乎是触发后续警告和错误.我一直在谷歌搜索疯狂,但没有找到任何清楚说明我应该做什么来解决这个问题.执行Ant构建时会发生此问题.我正在尝试将项目迁移到Java 7.我已将所有source ='1.6'和target ="1.6"更改为1.7.
我确实找到了这篇相关的文章:转发兼容的Java 6注释处理器和SupportedSourceVersion
它似乎表明我应该自己构建Hibernate注释处理器jar,用1.7编译它.似乎我不应该被要求这样做.有问题的类的最新版本(在hibernate-validator-annotation-processor-5.0.1.Final.jar中)已经用1.6编译.由于所述类中的代码引用SourceVersion.latestSupported(),并且1.6中的代码仅返回RELEASE_6,因此似乎没有通常可用的解决方案.
这是警告:
[javac] warning: Supported source version 'RELEASE_6' from annotation processor 'org.hibernate.validator.ap.ConstraintValidationProcessor' less than -source '1.7'
Run Code Online (Sandbox Code Playgroud)
并且,以下是后续警告/错误.
[javac] warning: No processor claimed any of these annotations: javax.persistence.PersistenceContext,javax.persistence.Column,org.codehaus.jackson.annotate.JsonIgnore,javax.persistence.Id,org.springframework.context.annotation.DependsOn,com.trgr.cobalt.infrastructure.datasource.Bucketed,org.codehaus.jackson.map.annotate.JsonDeserialize,javax.persistence.DiscriminatorColumn,com.trgr.cobalt.dataroom.authorization.secure.Secured,org.hibernate.annotations.GenericGenerator,javax.annotation.Resource,com.trgr.cobalt.infrastructure.spring.domain.DomainField,org.codehaus.jackson.annotate.JsonAutoDetect,javax.persistence.DiscriminatorValue,com.trgr.cobalt.dataroom.datasource.config.core.CoreTransactionMandatory,org.springframework.stereotype.Repository,javax.persistence.GeneratedValue,com.trgr.cobalt.dataroom.datasource.config.core.CoreTransactional,org.hibernate.annotations.Cascade,javax.persistence.Table,javax.persistence.Enumerated,org.hibernate.annotations.FilterDef,javax.persistence.OneToOne,com.trgr.cobalt.dataroom.datasource.config.core.CoreEntity,org.springframework.transaction.annotation.Transactional,com.trgr.cobalt.infrastructure.util.enums.EnumConversion,org.springframework.context.annotation.Configuration,com.trgr.cobalt.infrastructure.spring.domain.UpdatedFields,com.trgr.cobalt.infrastructure.spring.documentation.SampleValue,org.springframework.context.annotation.Bean,org.codehaus.jackson.annotate.JsonProperty,javax.persistence.Basic,org.codehaus.jackson.map.annotate.JsonSerialize,com.trgr.cobalt.infrastructure.spring.validation.Required,com.trgr.cobalt.dataroom.datasource.config.core.CoreTransactionNever,org.springframework.context.annotation.Profile,com.trgr.cobalt.infrastructure.spring.stereotype.Persistor,javax.persistence.Transient,com.trgr.cobalt.infrastructure.spring.validation.NotNull,javax.validation.constraints.Size,javax.persistence.Entity,javax.persistence.PrimaryKeyJoinColumn,org.hibernate.annotations.BatchSize,org.springframework.stereotype.Service,org.springframework.beans.factory.annotation.Value,javax.persistence.Inheritance
[javac] error: warnings found and -Werror specified
Run Code Online (Sandbox Code Playgroud)
TIA!
我在尝试保存实体时收到错误.我启动服务器时只会出现此错误,而不是在使用dbunit运行单元测试时.
我想保存一个协会.我的单元测试应该与手动测试时遇到的完全相同.我在关系的一端添加了一个新实体,之前没有任何关系.
我使用HSQLDB进行单元测试,Web应用程序正在使用SQL Server.
我所进行的搜索并未取得丰硕成果.对该消息的解释将证明是非常有用的.
这是测试用例(工作得很好!):
@Test
@DatabaseSetup(value="MobileWebsiteTest.saveMobilewebsiteMobilecolorswatchmapuserdefined_NewUserSwatch.xml", type=DatabaseOperation.REFRESH)
public void saveMobilewebsiteMobilecolorswatchmapuserdefined_NewUserSwatch() {
// given
Integer mobileWebsiteId = 569;
Mobilecolorswatchmapuserdefined expected = MobilecolorswatchmapuserdefinedBuilder.init().build();
// when
Mobilewebsite result = service.saveMobilewebsiteMobilecolorswatchmapuserdefined(mobileWebsiteId, expected);
// then
assertNotNull("The Mobilewebsite user defined swatch should not be null", result.getMobilecolorswatchmapuserdefined());
assertNotNull("The Mobilewebsite user defined swatch id should not be null.", result.getMobilecolorswatchmapuserdefined().getMobileColorSwatchMapUserDefinedId());
assertEquals("The result aside property should be equivalent to the expected aside property.", expected.getAside(), result.getMobilecolorswatchmapuserdefined().getAside());
assertEquals("The result SiteName property should be equivalent to the expected SiteName property.", expected.getSiteName(), …Run Code Online (Sandbox Code Playgroud)