- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我好久没有遇到这么令人费解的问题了。我有一个类引用另一个位于同一应用程序的另一个包中的类,也就是说,不在另一个 jar 存档文件中。
包含类是learnintouch-rest/src/test/java/com/thalasoft/learnintouch/rest/acceptance/AbstractControllerTest.java
包含的类是/home/stephane/dev/java/projects/learnintouch-rest/src/test/java/com/thalasoft/learnintouch/rest/config/WebTestConfiguration.java
在Eclipse下没有问题,编辑器也没有编译错误。
但运行 Maven 构建会产生编译错误:
mvn clean test-compile -Pacceptance
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project learnintouch-rest: Compilation failure: Compilation failure:
[ERROR] /home/stephane/dev/java/projects/learnintouch-rest/src/test/java/com/thalasoft/learnintouch/rest/acceptance/AbstractControllerTest.java:[16,46] cannot find symbol
[ERROR] symbol: class WebTestConfiguration
[ERROR] location: package com.thalasoft.learnintouch.rest.config
[ERROR] /home/stephane/dev/java/projects/learnintouch-rest/src/test/java/com/thalasoft/learnintouch/rest/acceptance/AbstractControllerTest.java:[21,116] cannot find symbol
[ERROR] symbol: class WebTestConfiguration
这是包含类的代码:
@RunWith(SpringJUnit4ClassRunner.class)
@Transactional
@WebAppConfiguration
@ContextConfiguration(classes = {
ApplicationConfiguration.class,
WebSecurityConfig.class,
WebConfiguration.class,
WebTestConfiguration.class
})
public abstract class AbstractControllerTest {
这个抽象测试类位于验收测试目录下,它要求在运行 Maven 命令时显式激活 -Pacceptance 配置文件。
默认配置文件不运行此验收测试,而仅运行一些集成测试。
需要注意的一点是,这个抽象类看起来就像集成测试中使用的一个抽象类。
这是集成测试的包含类:
import com.thalasoft.learnintouch.rest.config.WebTestConfiguration;
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(classes = {ApplicationConfiguration.class},
WebSecurityConfig.class,
WebConfiguration.class,
WebTestConfiguration.class
})
@Transactional
public abstract class AbstractControllerTest {
如您所见,它看起来很像另一个。
如果有帮助,我也可以给 pom.xml 文件内容:
<profiles>
<profile>
<id>rest</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<test.source.dir>src/test/java/com/thalasoft/learnintouch/rest</test.source.dir>
</properties>
</profile>
<profile>
<id>acceptance</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<test.source.dir>src/test/java/com/thalasoft/learnintouch/rest/acceptance</test.source.dir>
</properties>
</profile>
</profiles>
如果您对此有任何线索,将不胜感激。
最佳答案
使用 maven,您的测试可以访问项目的所有源代码(src/main/java)和所有测试源代码(默认为 src/test/java)。
在这里,您的配置文件 rest 将测试源目录定义为 src/test/java/com/thalasoft/learnintouch/rest因此,您的测试代码可以访问 src/main/java 中的所有内容以及 src/test/java/com/thalasoft/learnintouch/rest 中的所有内容
您的个人资料 acceptance 将测试源目录定义为 src/test/java/com/thalasoft/learnintouch/rest/acceptance因此,您的测试代码可以访问 src/main/java 中的所有内容以及 src/test/java/com/thalasoft/learnintouch/rest/acceptance 中的所有内容。WebTestConfiguration 不可访问,因为它在上面的包中。
要使用不同的配置文件运行特定测试,我建议配置负责运行测试的 surefire 插件。这里有一个很好的例子:https://weblogs.java.net/blog/carcassi/archive/2011/04/21/running-integration-tests-and-unit-tests-separately-maven
关于java - Maven 编译给出 : Cannot find symbol - For a class sitting in the same app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23327920/
我们的开发环境是这样配置的,当我们运行代码的调试版本时,它会在崩溃或 ^C 时进入 gdb。随着最近的一些更改,这种情况不再发生(退出程序而不是进入 gdb),我怀疑符号大小的增加导致了这个问题。 有
刚刚浏览了一个教程,想到了我看到的地方 first_name: 还有一个地方 :first_name 这样对吗?有什么区别? 最佳答案 哈希语法在 Ruby 1.9.2 中发生了变化,以更接近 jso
这里是一个相当抽象的问题,因为我不知道从哪里开始我自己的调查。 我有一个用 CMake 构建的 C 包,它生成 librpdb.so;我为同一个库设置了一个 Ruby Gem,它生成 rpdb.bun
我尝试使用 Symbol 创建对象键并用 Symbol.for 找到对应的值,但它不起作用: const sym = Symbol("x"); let obj = { [sym]: "val" }
这可能是一个愚蠢的问题,但我很高兴知道为什么我们使用带有一些标志的短形式的单符号和带有完整标志的双符号? 例子: 1) -h & --help 2) -f & --force 谁能解释一下原因? 最
我们希望能够在删除物理构建区域时删除符号服务器内容,symstore del 命令对事务 ID 起作用。这是未知的。 How to extract the transaction ID based o
我在一个我不太理解的小程序上遇到这个问题(我对节点红色有点陌生),代码是 var profile = msg.user.profile; var cart = profile.cart = pr
我正在尝试创建一种工资单以在控制台中打印,但我从代码中收到以下错误。很多时候它实际上只是一个错误,但我认为我没有足够的 java 知识来自己修复它。 import java.io.*; import
在 C# 项目中,我在 UnhandledException 中创建了小型转储。在我的 Dev 机器中,项目源和 bin 位于路径 K:\projects\*MYPROJECT* 下,如果我设法让它在
我正在尝试针对另一个使用 libcurl 共享库的共享库 (libtheirstuff.so) 交叉编译我自己的共享库 (libmystuff.so),但出现以下错误: libmystuff.so:
我试图遍历一个数组来检查它是否包含任何通过指定函数的项目。我通过向 Array 对象添加一个 .any() 原型(prototype)来做到这一点: Array.prototype.any = (co
除了这个 undefined symbol 错误外,一切正常: bash-3.2$ make g++ -Wall -g solvePlanningProblem.o Position.o AStarN
我 rsync 目录“Promotion”包含两台具有不同目录结构的机器之间的绝对符号链接(symbolic link)。因此绝对符号链接(symbolic link)在两台机器上都不起作用。为了使它
我有以下 JSX - What is your e-mail address? setStateForProperties(e)}
根据 SVG 的 symbol文档,我可以添加 refX/refY属性给它。 如果我理解正确,我可以使用这些属性来定义符号坐标系中的引用点,因此当我使用 引用它时元素,它将相对于该引用点(而不是默认
请解释以下有关“找不到符号”,“无法解析符号”或“找不到符号”错误的信息: 是什么意思? 什么原因可以导致它们? 程序员如何解决它们? 该问题旨在对Java中的这些常见编译错误进行全面的问答。 最佳答
请解释以下有关“找不到符号”,“无法解析符号”或“找不到符号”错误的信息: 是什么意思? 什么原因可以导致它们? 程序员如何解决它们? 该问题旨在对Java中的这些常见编译错误进行全面的问答。 最佳答
请解释以下有关“找不到符号”,“无法解析符号”或“找不到符号”错误的信息: 是什么意思? 什么原因可以导致它们? 程序员如何解决它们? 该问题旨在对Java中的这些常见编译错误进行全面的问答。 最佳答
请解释以下有关“找不到符号”,“无法解析符号”或“找不到符号”错误的信息: 是什么意思? 什么原因可以导致它们? 程序员如何解决它们? 该问题旨在对Java中的这些常见编译错误进行全面的问答。 最佳答
请解释以下有关“找不到符号”,“无法解析符号”或“找不到符号”错误的信息: 是什么意思? 什么原因可以导致它们? 程序员如何解决它们? 该问题旨在对Java中的这些常见编译错误进行全面的问答。 最佳答
我是一名优秀的程序员,十分优秀!