Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » [Oxygen] Eclipse Scout/ Spring Boot - MapStruct and Lombok and Maven
[Oxygen] Eclipse Scout/ Spring Boot - MapStruct and Lombok and Maven [message #1784160] Fri, 23 March 2018 05:15 Go to next message
Peter Pfeifer is currently offline Peter PfeiferFriend
Messages: 211
Registered: November 2014
Senior Member

Hello there,

I'm playing around a lot with the combination Eclipse Scout and Spring Boot recently.

And I must admit developing business apps wasn't so much fun till these two frameworks came together.

Since I'm trying to avoid as much boilerplate code as possible I also use Lombok and MapStruct.

From within Eclipse everything works fine. The code for my Lombok classes (thanks to the integrated Lombok agent) and and the *Impl classes for MapStruct interfaces is generated on the fly and everything is up and running. There aren't any problems and it works flawlessly.

But when it comes to building the source code on the command line with maven these two guys don't work anymore. In order to find out what could possibly go wrong I tracked the problem down by first generating a simple Java Maven project and then a plain Spring Boot project.

I did exactly as it was described in the respective documentation and just added the dependencies as mentioned. Lo and behold, everything works as expected. The code is generated with maven on the command line and my classes are extended with getter/setter by Lombok and MapStruct pre-processor kicks in and the corresponding *Impl classes are generated.

Now I assume that some dependencies (perhaps certain versions) along the dependency tree within the ScoutBoot setup prevent those two from working.

Unfortunately I have no clue how to find out, which dependency this might be. I'm searching around, but with no luck.

Is there anybody out there, who might have a clue and might be able to help. Right now I'm a little bit frustrated that I can't get the maven build to work on the command line.

Any help is deeply appreciated.

Thanks, Peter
Re: [Oxygen] Eclipse Scout/ Spring Boot - MapStruct and Lombok and Maven [message #1786313 is a reply to message #1784160] Mon, 30 April 2018 15:27 Go to previous messageGo to next message
gaige shen is currently offline gaige shenFriend
Messages: 3
Registered: April 2018
Junior Member
I installed lombok and mapstruct for my eclipse(STS),but not work, the lombok works fine, but the mapstruct not work, could not generate *Impl class file.Can you add my QQ number for discuss this.Or Email gaigeshen@qq.com.
Re: [Oxygen] Eclipse Scout/ Spring Boot - MapStruct and Lombok and Maven [message #1786363 is a reply to message #1786313] Wed, 02 May 2018 06:13 Go to previous messageGo to next message
Patrick Bänziger is currently offline Patrick BänzigerFriend
Messages: 69
Registered: September 2011
Member
@Gaige Shen: Is your question regarding Eclipse Scout and the combination with Lombok Mapstruct?
Otherwise this is probably the wrong forum to ask: The Spring Tools Suite is Eclipse based, but produced and released by Pivotal.
Your question (with more information like error message) might be better suited for another forum, or StackOverflow.

@Peter: Sounds like an exciting combination. No one on our team has worked with that specific combination of frameworks yet, but if you can post what exactly goes wrong when you're building we may have some pointers.
Re: [Oxygen] Eclipse Scout/ Spring Boot - MapStruct and Lombok and Maven [message #1786394 is a reply to message #1786363] Wed, 02 May 2018 15:35 Go to previous messageGo to next message
Peter Pfeifer is currently offline Peter PfeiferFriend
Messages: 211
Registered: November 2014
Senior Member

Hi there,

Patrick Bänziger wrote on Wed, 02 May 2018 06:13
@@Peter: Sounds like an exciting combination. No one on our team has worked with that specific combination of frameworks yet, but if you can post what exactly goes wrong when you're building we may have some pointers.


Yeah I like that combination very much. It saves me a lot of time, since I dont have to write or generate setters/getters anymore.

I stumble across MapStruct and somehow liked it better than ModelMapper.

In the meanwhile I got the maven command line build working (which helps me a lot to setup a CI/CD with Jenkins).

I found out that within the whole Scout / Spring Boot setting the Maven Compile Plugin version 3.1 was used.

Those tools mentioned above need at least version 3.6.1 or above. So here is what I did. I set the
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>


and then overrode the setting for the maven compiler plugin configuration with " combine.self="override""
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<version>3.7.0</version>
	<configuration combine.self="override">
		<source>1.8</source>
		<target>1.8</target>
		<annotationProcessorPaths>
			<path>
				<groupId>org.mapstruct</groupId>
				<artifactId>mapstruct-processor</artifactId>
				<version>${org.mapstruct.version}</version>
			</path>
		</annotationProcessorPaths>
	</configuration>
</plugin>


These 2 changes helped me to get the maven build working.

Another thing that might help, would be an upgrade to Spring Boot 2.x with Eclipse Scout 7.0 or higher ;)

I must admit I really like the Eclipse Scout/Spring Boot combination. It makes writing awesome looking business application more fun and gives you simple access to the Spring universe (Caching, Hibernate Search Integration, ...)

Peter
Re: [Oxygen] Eclipse Scout/ Spring Boot - MapStruct and Lombok and Maven [message #1786411 is a reply to message #1786394] Thu, 03 May 2018 00:42 Go to previous messageGo to next message
gaige shen is currently offline gaige shenFriend
Messages: 3
Registered: April 2018
Junior Member
@Peter Pfeifer Is it works?
Re: [Oxygen] Eclipse Scout/ Spring Boot - MapStruct and Lombok and Maven [message #1786412 is a reply to message #1786411] Thu, 03 May 2018 00:46 Go to previous messageGo to next message
gaige shen is currently offline gaige shenFriend
Messages: 3
Registered: April 2018
Junior Member
@Patrick https://github.com/mapstruct/mapstruct/issues/1468
Re: [Oxygen] Eclipse Scout/ Spring Boot - MapStruct and Lombok and Maven [message #1786415 is a reply to message #1786411] Thu, 03 May 2018 04:58 Go to previous message
Peter Pfeifer is currently offline Peter PfeiferFriend
Messages: 211
Registered: November 2014
Senior Member

Hi,
gaige shen wrote on Thu, 03 May 2018 00:42
@Peter Pfeifer Is it works?


Yes it does.

My pom.xml for MapStruct looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>at.bfzgruenbach.shop</groupId>
		<artifactId>shop</artifactId>
		<version>0.0.1-SNAPSHOT</version>
		<relativePath>../bfz.shop</relativePath>
	</parent>
	<groupId>at.bfz-gruenbach.shop.standalone</groupId>

	<artifactId>standalone</artifactId>
	<version>1.0-SNAPSHOT</version>

	<dependencies>

		<dependency>
			<groupId>at.bfzgruenbach.shop.commons</groupId>
			<artifactId>dbmodel</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>
		<dependency>
			<groupId>at.bfzgruenbach.shop.commons</groupId>
			<artifactId>dto</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>
		<dependency>
			<groupId>at.bfzgruenbach.shop.commons</groupId>
			<artifactId>ui</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>
		<dependency>
			<groupId>org.mariadb.jdbc</groupId>
			<artifactId>mariadb-java-client</artifactId>
		</dependency>

		<dependency>
			<groupId>org.mapstruct</groupId>
			<artifactId>mapstruct-jdk8</artifactId>
			<version>${org.mapstruct.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-cache</artifactId>
		</dependency>
	</dependencies>

	<build>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
			</resource>
			<resource>
				<directory>src/main/js</directory>
			</resource>
		</resources>

		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<excludeDevtools>true</excludeDevtools>
					<excludeArtifactIds>scout-boot-ui-dev</excludeArtifactIds>
				</configuration>
			</plugin>
			<plugin>
				<groupId>io.fabric8</groupId>
				<artifactId>docker-maven-plugin</artifactId>
				<configuration>
					<images>
						<image>
							<name>at.bfz-gruenbach.shop.bfz.standalone:${project.version}</name>
							<alias>bfz.standalone</alias>
							<build>
								<dockerFileDir>${project.basedir}</dockerFileDir>
							</build>
						</image>
					</images>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.7.0</version>
				<configuration combine.self="override">
					<source>1.8</source> 
					<target>1.8</target> 
					<annotationProcessorPaths>
						<path>
							<groupId>org.mapstruct</groupId>
							<artifactId>mapstruct-processor</artifactId>
							<version>${org.mapstruct.version}</version>
						</path>
					</annotationProcessorPaths>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<name>bfz.standalone</name>
</project>


And for a project where I use Lombok the pom.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<artifactId>dbmodel</artifactId>
	<packaging>jar</packaging>

	<name>bfz.dbmodel</name>
	<description>Demo project for Spring Boot</description>

	<parent>
		<groupId>at.bfzgruenbach.shop.commons</groupId>
		<artifactId>commons</artifactId>
		<version>0.0.1-SNAPSHOT</version>
		<relativePath>../bfz.commons</relativePath>
	</parent>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
			<version>1.5.8.RELEASE</version>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<version>1.5.8.RELEASE</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>at.bfzgruenbach.shop.commons</groupId>
			<artifactId>dto</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>

		<!-- lombok dependencies should not end up on classpath -->
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<version>${org.projectlombok.version}</version>
			<scope>provided</scope>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.7.0</version>
				<configuration combine.self="override">
					<source>1.8</source>
					<target>1.8</target>
					<annotationProcessorPaths>
						<path>
							<groupId>org.projectlombok</groupId>
							<artifactId>lombok</artifactId>
							<version>${org.projectlombok.version}</version>
						</path>
					</annotationProcessorPaths>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>


Hope this helps.

Peter
Previous Topic:properties are not found while starting client in dev mode
Next Topic:Creating new Scout project
Goto Forum:
  


Current Time: Thu Nov 15 12:09:15 GMT 2018

Powered by FUDForum. Page generated in 0.02060 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top