- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
是否有文档或示例说明了如何成功地将 MapStruct 1.3.1 与 Eclipse 2020-03 和 Gradle/Buildship 集成,并描述了生成 MapStruct 实现类需要做什么?我已经进行了相当多的搜索和阅读,但尝试了很多事情后似乎无法确定它。
我的项目设置是 Gradle 多项目设置,在我尝试通过 Gradle 添加 MapStruct 之前它运行良好。我的项目中有带有注释的 JAX-RS REST 类,我看到的问题似乎在某种程度上与注释处理有关,因为构建失败并出现 REST 类中注释的编译错误(请参阅异常输出以下)。
任何指针,进一步阅读,修复都是受欢迎的,非常感谢。
运行相关 build
时遇到的异常Eclipse 的 Gradle Tasks View 中的任务是:
D:\<placeholder>\PlanContractualDetails.java:527: error: cannot find symbol
@ApiModelProperty(example = "null", required = true, value = "True - life time investment option phasing applicable. Please note that this value will be always populated by using the active LTIO on the plan, irrespective of the effectiveDate passed by the caller.")
^
symbol: class ApiModelProperty
location: class PlanContractualDetails
100 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':epsilon-plan-service:compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 563ms
1 actionable task: 1 executed
build.gradle
如下:
/*
* Project build file.
*/
/* Plugin configuration */
plugins {
id 'java'
id 'war'
id 'eclipse-wtp'
}
sourceCompatibility = JavaVersion.VERSION_1_8
/* Project dependencies */
dependencies {
compile "org.mapstruct:mapstruct-jdk8:${mapstructVersion}"
testCompile 'org.testng:testng:6.10', 'org.easytesting:fest-assert:1.4'
compile "org.mapstruct:mapstruct-processor:${mapstructVersion}"
compile "javax.ws.rs:javax.ws.rs-api:2.0.1"
providedCompile "javax.servlet:javax.servlet-api:3.1.0"
// --- Mapstruct ---------------------------------
// https://mvnrepository.com/artifact/org.mapstruct/mapstruct-jdk8
//compile group: 'org.mapstruct', name: 'mapstruct-jdk8', version: '1.3.1.Final'
// https://mvnrepository.com/artifact/org.mapstruct/mapstruct-processor
//compile group: 'org.mapstruct', name: 'mapstruct-processor', version: '1.3.1.Final'
//compile "org.mapstruct:mapstruct:${mapstructVersion}"
// If you are using mapstruct in test code
//testAnnotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}"
//compileOnly("org.mapstruct:mapstruct-jdk8:${mapstructVersion}")
//annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}"
//compileOnly "javax:javaee-api:${javaee_api_version}"
}
tasks.withType(JavaCompile) {
options.compilerArgs = [
'-Amapstruct.suppressGeneratorTimestamp=true'
]
}
sourceSets.main.java.srcDirs += 'src'
//sourceSets.main.kotlin.srcDirs += myDir
/* Eclipse configuration */
ext.outputDir = 'src/main/webapp/WEB-INF/classes'
eclipse {
/*
project {
natures 'org.eclipse.buildship.core.gradleprojectnature'
//buildCommands.clear();
//buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
}
*/
classpath {
defaultOutputDir = file("${outputDir}")
file.whenMerged {
entries.each {
source ->
// This seems kludgy.
if (source.kind == 'src' && source.toString().contains('output=') && source.output.contains("${eclipse_default_output_dir}")) {
source.output = "${outputDir}"
}
}
}
}
/*
Deal with project facets.
See: https://stackoverflow.com/questions/48828869/how-to-convert-java-gradle-project-to-dynamic-web-project
And: https://discuss.gradle.org/t/easily-customize-the-eclipse-wtp-facet-version/8690
And: https://github.com/gradle/gradle/issues/1334
*/
wtp {
facet {
file {
withXml {
/*
Ensure that the Eclipse facet metadata in the file .settings/org.eclipse.wst.common.project.facet.core.xml
is preserved after running this build script. This is needed as Gradle overwrites this file and defaults
some of the entries to older versions which may result in both Eclipse metadata and Gradle build errors.
*/
def node = it.asNode()
/*
This runtime facet is specifically for Eclipse projects such as a Dynamic Web Project project created
for development, deployment and debugging on WebSphere Application Server traditional V9.0.
The name: must correspond to the name Properties -> Project Facets -> Runtimes tab entry
that is ticked for this Eclipse project.
*/
node.appendNode('runtime', [name: 'WebSphere Application Server traditional V9.0'])
}
def oldJstWebFacet = facets.findAll {
it.name == 'jst.web' && it.version == '2.4'
}
facets.removeAll(oldJstWebFacet)
facet name: 'jst.web', version: '3.1'
/*
Additional Eclipse project facets for WebSphere 9 traditional.
*/
facet name: 'com.ibm.websphere.coexistence.web', version: '9.0'
facet name: 'com.ibm.websphere.extended.web', version: '9.0'
//facet name: 'java', version: '1.8'
}
}
}
}
test {
useTestNG()
}```
最佳答案
我的问题原来不是 MapStruct 问题,也与注释处理无关。我再次从头开始,但在生成任何 JAX-RS 或 MapStruct 代码之前,测试了 MapStruct Gradle 配置并运行。然后添加了一些 MapStruct 示例代码,它仍然很高兴;添加 JAX-RS 绑定(bind)会导致构建失败。修复是添加正确的 JAX-RS 依赖项并通过运行 Eclipse 清理和构建任务来重建 Eclipse 元数据。
关于eclipse - 如何成功集成 Gradle、MapStruct 1.3.1 和 Eclipse 2020-03?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61000124/
我可以在我们有 String 到 Enum 映射的地方找到答案,但我找不到如何将 Enum 映射到 String。 public class Result { Value enumValue; }
我想使用 MapStruct 映射一个没有源对象的 Target 对象。我试过了,但出现以下错误。 Can't generate mapping method with no input argume
我在单独的文件中有这 3 个类 public class Book { @Id @GeneratedValue private Long id; @NonNull
如何使用 MapStruct 对于以下场景进行 bean 映射。 class Source { private String sourceId; private List courses; //al
是否可以在针对目标 bean 中字符串类型的 bean 属性设置字符串值之前对其进行修剪? 例如,Dozer 通过其映射配置提供了这样的功能, true 另见 Dozer Global C
我收到编译错误: com/mycompany/hibernate5/Main.java:[10,46] cannot find symbol symbol: class Customer_
目前我们在项目中使用 ModelMapper。但是,在该站点中,我看到很多人喜欢 MapStruct。 不确定差异以及我们是否需要真正进行升级。 ModelMapper 和 MapStruct 有什么
我正在使用 map 结构用于在我的 中将 Dto 映射到实体,反之亦然 Spring Boot 应用。 I want to know that, is there a way that i can m
如何在 MapStruct 中完全禁用“构建器”?我根本不想使用它们,因为它们给我带来了各种各样的问题。 我在 META-INF 下创建了服务文件(我更喜欢一种将它分配给映射构建器 = 的方法,但我没
@Mapper @Mapper 将接口或抽象类标记为映射器,并自动生成映射实现类代码。 public @interface Mapper { // 引入其他其他映射器 Class&
我在其他地方看到过这个问题,但不是在相同的上下文中,也没有适合我们用例的答案。 假设我在源对象中有一个列表字段: List mySourceList; 和相应的目标字段: List myTargetL
我在 MapStruct 中使用 spring data jdbc。 POJO 与具有所有“仅限内部”数据(如代理键、审计信息等)的表结构保持一致,而域对象是分层的并且仅包含业务相关数据。我必须在特定
页面信息 public class PageInfoDto implements Serializable { private int currentPageNum; private
在 MapStruct 版本 1.1.0.Final 中,这是可能的.... @Mappings({ @Mapping(target = "transaction.process.detail
我有一个 list List我想映射到另一个列表 List .这些类型如下所示: public class Payment { @XmlElement(name = "Installment"
我要单例Mapper两者兼而有之 create和 update方法。 create 方法生成的代码很好,但是在更新的情况下,我想在目标中设置属性,前提是它们在源中不为空。 我该怎么做 mapStruc
我想使用 mapstruct 在这些对象之间进行映射: MyObj1 -List myObj2List --List myObj3List ---string field1 MyObj4 -List
如何映射以下内容: class Source { String name; List others; } class Other { String otherName; Lis
我想映射以下类 class Schedule { ZoneId timezoneId; List rules; } class AvailabilityRule { long
我是 MapStruct API 的新手,谁能说一下如何进行嵌套映射。 我有两个类,一个是我实际的purchaseOrder 类,它是我的目标类,另一个是EDPurchaseOrder 类,它被称为源
我是一名优秀的程序员,十分优秀!