我有一个自定义的 hybris 组件。我将以下内容添加到 external-dependencies.xml
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<scope>provided</scope>
</dependency>
Lombok 插件已安装,注释处理已启用。在 IDE 中,我看到了生成的方法,但是当我运行 ant clean all
时,我得到了错误。
例如这里是一个测试类:
@Data
public class TestDto {
private String prop;
}
下面是一个例子
TestDto test = new TestDto();
test.setProp("");
test.getProp();
但是 ant clean all
说了以下内容:
[yjavac] Compiling 700 source files to /Users/myUser/Projects/MyProject/hybris/myComponent/classes
[yjavac] ----------
[yjavac] 1. ERROR in /Users/myUser/Projects/MyProject/hybris/myComponent/src/service/ExampleService.java (at line 65)
[yjavac] test.setProp("");
[yjavac] ^^^^^^^
[yjavac] The method setProp(String) is undefined for the type TestDto
[yjavac] ----------
[yjavac] 2. ERROR in /Users/myUser/Projects/MyProject/hybris/myComponent/src/service/ExampleService.java (at line 66)
[yjavac] test.getProp();
[yjavac] ^^^^^^^
[yjavac] The method getProp() is undefined for the type TestDto
[yjavac] ----------
[yjavac] 2 problems (2 errors)
BUILD FAILED
我错过了什么?
编辑:
这是extensioninfo.xml
。 Maven 已启用。
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<extensioninfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="extensioninfo.xsd">
<extension abstractclassprefix="Generated" classprefix="MyPrefix" managername="MyManager"
managersuperclass="de.hybris.platform.jalo.extension.Extension" name="myName" usemaven="true">
<requires-extension name="Mycore"/>
<requires-extension name="Mymqintegration"/>
<requires-extension name="Mycommons"/>
<coremodule generated="true" manager="com.example.api.jalo.MyManager"
packageroot="com.example.api"/>
<webmodule jspcompile="false" webroot="/api"/>
</extension>
</extensioninfo>
编辑2:
我发现了一些关于 buildcallbacks.xml
的提示。我是 hybris 的新手,所以我搜索了一些谷歌 -> 复制 -> 粘贴 -> 尝试 -> 使用 buildcallbacks 重复循环,但没有找到适合我的解决方案。
下面是一些我试过但没有成功的例子:
<target name="myModuleName_lombok">
<javac srcdir="src" destdir="build" source="1.8">
<classpath location="lib/lombok-1.18.12.jar"/>
</javac>
<echo message=" adding lombok"/>
</target>
<macrodef name="myExtName_before_build">
<sequential>
<addToClasspath classpathproperty="ext.MyExtName.classpath" path="${ext.MyExtname.path}/lib/lombok-1.18.12.jar"/>
</sequential>
</macrodef>
最佳答案
我无法对 Lombok 发表评论,因为我还没有在 Hybris 中使用过它。但是,通常(并且可能是正确的方法)创建数据或 DTO 类是通过 *-beans.xml。
你通常会有这样的东西:
<bean class="com.demo.facades.dto.TestDto">
<property name="prop" type="String" />
</bean>
引用:
关于java - Lombok 不会在 hybris 自定义组件中生成 getter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62305034/