Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Useful link https://www.baeldung.com/executable-jar-with-maven#bd-thymeleaf-4

The command to create a new maven project 

...

Code Block
languagexml
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.4.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.celestial.App</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin> 

OR

Code Block
languagexml
    <build>  
        <plugins>
            <plugin>    
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                </configuration>   
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.4.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.lbg.coh2.App</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>    
        </plugins>
    </build>


Springboot Applications

When working with Sprinboot, use this plugin

Code Block
	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
						<configuration>
							<classifier>spring-boot</classifier>
							<mainClass>
								com.celestial.vatcsl.VatCalculatorServiceApplication
							</mainClass>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>


Latest Maven plugin that builds an executable with MainClass path

Code Block
  <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-shade-plugin</artifactId>
          <executions>
            <execution>
              <goals>
                <goal>shade</goal>
              </goals>
              <configuration>
                <finalName>kafka_demo</finalName>
                <shadedArtifactAttached>true</shadedArtifactAttached>
                <transformers>
                  <transformer implementation=
                                       "org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                    <mainClass>org.celestial.kafka.producer.App</mainClass>
                  </transformer>
                </transformers>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
  </build>