JavaLombok不会在hybris自定义组件中生成getter
我有一个定制的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>
# 1 楼答案
我不能评论龙目山,因为我还没有在海布里斯用过它。但是,创建数据或DTO类的通常方法(可能也是正确的方法)是通过*-bean。xml
你通常会有这样的东西:
参考:
# 2 楼答案
问题在于蚂蚁构建的方式:
https://projectlombok.org/setup/ant
要在ant中实现这种定制,请创建一个名为buildcallbacks的文件。xml及其扩展:
https://wiki.hybris.com/x/YIVvAg