Lombok creating gets and sets in compiled class but not the generated-sources in Eclipse 2020-09

huangapple go评论77阅读模式
英文:

Lombok creating gets and sets in compiled class but not the generated-sources in Eclipse 2020-09

问题

I've installed the Lombok using java -jar lombok-1.18.14.jar getting successful message into Eclipse 2020-09 (4.17) but it's not appearing in About window.

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>redact</groupId>
	<artifactId>redact</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>

	<properties>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
		<maven.compiler.plugin>3.5.1</maven.compiler.plugin>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<failOnMissingWebXml>false</failOnMissingWebXml>
		<springFramework>5.2.9.RELEASE</springFramework>
		<springSecurity>5.4.1</springSecurity>
		<thymeleaf>3.0.11.RELEASE</thymeleaf>
		<thymeleafSecurity>3.0.4.RELEASE</thymeleafSecurity>
		<mysql>8.0.21</mysql>
		<logback>1.2.3</logback>
		<slf4j>1.7.30</slf4j>
		<mapStruct>1.4.0.Final</mapStruct>
		<lombok>1.18.14</lombok>
	</properties>

	<dependencies>
		<!-- Servlet API Dependency -->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<version>2.5</version>
		</dependency>
		<dependency>
			<groupId>javax.servlet.jsp</groupId>
			<artifactId>jsp-api</artifactId>
			<version>2.1</version>
		</dependency>

		<!-- Spring Framework Dependencies -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${springFramework}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${springFramework}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${springFramework}</version>
		</dependency>

		<!-- Spring Data Dependencies -->
		<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-jpa</artifactId>
			<version>2.3.4.RELEASE</version>
		</dependency>

		<!-- Spring Security Dependencies -->
		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-web</artifactId>
			<version>${springSecurity}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-config</artifactId>
			<version>${springSecurity}</version>
		</dependency>

		<!-- Spring JDBC dependency -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
			<version>${springFramework}</version>
		</dependency>

		<!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api -->
		<dependency>
			<groupId>javax.persistence</groupId>
			<artifactId>javax.persistence-api</artifactId>
			<version>2.2</version>
		</dependency>

		<dependency>
			<groupId>org.hibernate.validator</groupId>
			<artifactId>hibernate-validator</artifactId>
			<version>6.0.13.Final</version>
		</dependency>

		<!-- Mysql connector dependency -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>${mysql}</version>
		</dependency>

		<!-- JSTL Dependency -->
		<dependency>
			<groupId>jstl</groupId>
			<artifactId>jstl</artifactId>
			<version>1.2</version>
		</dependency>

		<!-- Thymeleaf -->
		<dependency>
			<groupId>org.thymeleaf</groupId>
			<artifactId>thymeleaf</artifactId>
			<version>${thymeleaf}</version>
		</dependency>
		<dependency>
			<groupId>org.thymeleaf</groupId>
			<artifactId>thymeleaf-spring5</artifactId>
			<version>${thymeleaf}</version>
		</dependency>
		<dependency>
			<groupId>org.thymeleaf.extras</groupId>
			<artifactId>thymeleaf-extras-springsecurity5</artifactId>
			<version>${thymeleafSecurity}</version>
		</dependency>

		<!-- Logback -->
		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-core</artifactId>
			<version>${logback}</version>
		</dependency>

		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-classic</artifactId>
			<version>${logback}</version>
		</dependency>

		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>${slf4j}</version>
		</dependency>

		<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<version>${lombok}</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok-mapstruct-binding</artifactId>
			<version>0.1.0</version>
		</dependency>

		<dependency>
			<groupId>org.mapstruct</groupId>
			<artifactId>mapstruct

<details>
<summary>英文:</summary>

I&#39;ve installed the Lombok using `java -jar lombok-1.18.14.jar` getting successful message into Eclipse 2020-09 (4.17) but it&#39;s not appearing in About window.

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;>
<modelVersion>4.0.0</modelVersion>
<groupId>redact</groupId>
<artifactId>redact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

&lt;properties&gt;
&lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
&lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
&lt;maven.compiler.plugin&gt;3.5.1&lt;/maven.compiler.plugin&gt;
&lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
&lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
&lt;springFramework&gt;5.2.9.RELEASE&lt;/springFramework&gt;
&lt;springSecurity&gt;5.4.1&lt;/springSecurity&gt;
&lt;thymeleaf&gt;3.0.11.RELEASE&lt;/thymeleaf&gt;
&lt;thymeleafSecurity&gt;3.0.4.RELEASE&lt;/thymeleafSecurity&gt;
&lt;mysql&gt;8.0.21&lt;/mysql&gt;
&lt;logback&gt;1.2.3&lt;/logback&gt;
&lt;slf4j&gt;1.7.30&lt;/slf4j&gt;
&lt;mapStruct&gt;1.4.0.Final&lt;/mapStruct&gt;
&lt;lombok&gt;1.18.14&lt;/lombok&gt;
&lt;/properties&gt;
&lt;dependencies&gt;
&lt;!-- Servlet API Dependency --&gt;
&lt;dependency&gt;
&lt;groupId&gt;javax.servlet&lt;/groupId&gt;
&lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
&lt;version&gt;2.5&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
&lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
&lt;version&gt;2.1&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- Spring Framework Dependencies --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework&lt;/groupId&gt;
&lt;artifactId&gt;spring-core&lt;/artifactId&gt;
&lt;version&gt;${springFramework}&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework&lt;/groupId&gt;
&lt;artifactId&gt;spring-context&lt;/artifactId&gt;
&lt;version&gt;${springFramework}&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework&lt;/groupId&gt;
&lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
&lt;version&gt;${springFramework}&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- Spring Data Dependencies --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
&lt;artifactId&gt;spring-data-jpa&lt;/artifactId&gt;
&lt;version&gt;2.3.4.RELEASE&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- Spring Security Dependencies --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
&lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
&lt;version&gt;${springSecurity}&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
&lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
&lt;version&gt;${springSecurity}&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- Spring JDBC dependency --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework&lt;/groupId&gt;
&lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
&lt;version&gt;${springFramework}&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api --&gt;
&lt;dependency&gt;
&lt;groupId&gt;javax.persistence&lt;/groupId&gt;
&lt;artifactId&gt;javax.persistence-api&lt;/artifactId&gt;
&lt;version&gt;2.2&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.hibernate.validator&lt;/groupId&gt;
&lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
&lt;version&gt;6.0.13.Final&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- Mysql connector dependency --&gt;
&lt;dependency&gt;
&lt;groupId&gt;mysql&lt;/groupId&gt;
&lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
&lt;version&gt;${mysql}&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- JSTL Dependency --&gt;
&lt;dependency&gt;
&lt;groupId&gt;jstl&lt;/groupId&gt;
&lt;artifactId&gt;jstl&lt;/artifactId&gt;
&lt;version&gt;1.2&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- Thymeleaf --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.thymeleaf&lt;/groupId&gt;
&lt;artifactId&gt;thymeleaf&lt;/artifactId&gt;
&lt;version&gt;${thymeleaf}&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.thymeleaf&lt;/groupId&gt;
&lt;artifactId&gt;thymeleaf-spring5&lt;/artifactId&gt;
&lt;version&gt;${thymeleaf}&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.thymeleaf.extras&lt;/groupId&gt;
&lt;artifactId&gt;thymeleaf-extras-springsecurity5&lt;/artifactId&gt;
&lt;version&gt;${thymeleafSecurity}&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- Logback --&gt;
&lt;dependency&gt;
&lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
&lt;artifactId&gt;logback-core&lt;/artifactId&gt;
&lt;version&gt;${logback}&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
&lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
&lt;version&gt;${logback}&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.slf4j&lt;/groupId&gt;
&lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
&lt;version&gt;${slf4j}&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
&lt;artifactId&gt;lombok&lt;/artifactId&gt;
&lt;version&gt;${lombok}&lt;/version&gt;
&lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
&lt;artifactId&gt;lombok-mapstruct-binding&lt;/artifactId&gt;
&lt;version&gt;0.1.0&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.mapstruct&lt;/groupId&gt;
&lt;artifactId&gt;mapstruct&lt;/artifactId&gt;
&lt;version&gt;${mapStruct}&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.mapstruct&lt;/groupId&gt;
&lt;artifactId&gt;mapstruct-processor&lt;/artifactId&gt;
&lt;version&gt;${mapStruct}&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.hibernate&lt;/groupId&gt;
&lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
&lt;version&gt;5.4.22.Final&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
&lt;build&gt;
&lt;plugins&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
&lt;version&gt;${maven.compiler.plugin}&lt;/version&gt;
&lt;configuration&gt;
&lt;annotationProcessorPaths&gt;
&lt;path&gt;
&lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
&lt;artifactId&gt;lombok&lt;/artifactId&gt;
&lt;version&gt;${lombok}&lt;/version&gt;
&lt;/path&gt;
&lt;path&gt;
&lt;groupId&gt;org.mapstruct&lt;/groupId&gt;
&lt;artifactId&gt;mapstruct-processor&lt;/artifactId&gt;
&lt;version&gt;${mapStruct}&lt;/version&gt;
&lt;/path&gt;
&lt;/annotationProcessorPaths&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/build&gt;

</project>


eclipse.ini:

-startup
plugins/org.eclipse.equinox.launcher_1.5.800.v20200727-1323.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.1300.v20200819-0940
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs -javaagent:D:\dev\eclipse\lombok.jar -Xbootclasspath/a:D:\dev\eclipse\lombok.jar
-Dosgi.requiredJavaVersion=11
-Dosgi.instance.area.default=@user.home/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=11
-Dosgi.dataAreaRequiresExplicitInit=true
-Xms256m
-Xmx2048m
--add-modules=ALL-SYSTEM
-javaagent:D:\dev\eclipse\lombok.jar

Originally, when I installed Lombok, only the last `-javaagent` was included. As soon as I opened the Eclipse, the **lombok/launch/PatchFixesHider$Transform** error happened ([as explained here][1]). 
I tried to install again and saw an information from the installer about the `-vm` and `-vmargs`. It says that if there is a custom -vm parameter, it&#39;s needed to put `-vmargs -javaaggent:lombok.jar` (all together) as well. There is no -vm at my .ini file, but I changed it anyway  file to include the -javaagent after -vmargs as instructed to test. The Patch error stopped, but the install still didn&#39;t work. 
I tried all possibilities with the -javaagent parameter and the Patch error only stopped if I put the parameter at same line as -vmargs.
If I remove the last line **-javaagent** or the **-Xbootclasspath** tag, nothing changes.
I tried installing Lombok versions `1.18.8` to `1.18.14` and `Eclipse Photon`, `2020-06` and `2020-09` (all possible combinations) and none worked.
When I put e.g. `user.getPassword()`, I get an error from Eclipse (method not defined), but Maven can build and install correctly (by bash or by Eclipse run as Maven)
I&#39;m using MapStruct and the generated-sources is being created correctly for them.
Something I realized doing my testing: Sometimes I&#39;m running the maven clean and install using bash because it&#39;s faster and the generated-sources are being created for MapStruct, but not for Lombok. So, I&#39;m having the same problem as Eclipse. So, would be the problem with Eclipse or with Maven? Would the Lombok sources be created using a pure mvn install?
Versions: 
- jdk1.8.0_172  
- jdk-11.0.8 (only installed to use Eclipse 2020-09)
- Lombok 1.18.8/10/12/14 (tried all versions)
- Eclipse Photon/2020-06/2020-09 (tried all these versions)
[1]: https://stackoverflow.com/questions/49532565/lombok-is-not-working-with-eclipse-kepler
</details>
# 答案1
**得分**: 0
[Lombok 1.18.14 无法在 Eclipse 2020-09 (4.17.0) 中安装][1]。
作为此已知问题的解决方法,**请改用 [Lombok 1.18.12][2]**。
[1]: https://github.com/rzwitserloot/lombok/issues/2599
[2]: https://projectlombok.org/all-versions
<details>
<summary>英文:</summary>
[Lombok 1.18.14 fails to be installed in Eclipse 2020-09 (4.17.0)][1].
As workaround for this known issue **use [Lombok 1.18.12][2] instead**.
[1]: https://github.com/rzwitserloot/lombok/issues/2599
[2]: https://projectlombok.org/all-versions
</details>
# 答案2
**得分**: 0
经过多次尝试和失败,我终于让它工作了。
这个问题与[此问题][1]有关。
我尝试安装了许多不同版本的 Lombok,从 1.18.8 到 1.18.14,但都失败了。为了最后一次测试,我从我的 .m2 仓库中删除了所有版本,只保留了 1.18.12 版本,然后重新运行安装,这次成功了。
如果有人遇到这个问题,我的建议是清除 .m2 仓库中的所有 Lombok 版本,删除 eclipse.ini 文件中任何与 Lombok 相关的 -javaagent,并使用 1.18.12 版本进行干净安装。
非常感谢 @howlger,他帮了我很多,还向我展示了这个问题。
[1]: https://github.com/rzwitserloot/lombok/issues/2599
<details>
<summary>英文:</summary>
After many tries and failures, I could make it work. 
This problem is related with [this issue][1].
I&#39;ve tried to install many different Lombok versions, from 1.18.8 to 1.18.14 failing all the time. To have a last test, I deleted all versions from my .m2 repository and kept only the 1.18.12 version, running the installation again and it worked.
If someone is facing this problem, my suggestion is clear all versions of Lombok from .m2 repository, delete any -javaagent referred to Lombok from eclipse.ini file and make a clean install using 1.18.12 version.
Many thanks to @howlger who helped me a lot and showed me the issue.
[1]: https://github.com/rzwitserloot/lombok/issues/2599
</details>

huangapple
  • 本文由 发表于 2020年10月11日 18:15:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/64302892.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定