I have one. Parent-module and two Child. One of the child is a plugin I wrote for sending mail to email(mail parameters, themes, text are set in pom.xml), which should be sent during the compilation phase of the parent-module. The second child is just a class with "Hello World".
My question. How do I do in the parent module: install maven plugin before the compilation phase?
p.s. I can not correctly form a question, because a huge request to clarify the nuances in the comments or add the missing information.
upd:
this is child-plugin
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>maven-parent</artifactId>
<groupId>com.live.hello</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>maven-plugin</packaging>
<artifactId>child-plugin</artifactId>
<dependencies>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.6.3</version>
</dependency>
</dependencies>
</project>
this is child-app
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>maven-parent</artifactId>
<groupId>com.live.hello</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>child-app</artifactId>
</project>
and parent
<?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>
<groupId>com.live.hello</groupId>
<artifactId>maven-parent</artifactId>
<version>1.0.0</version>
<modules>
<module>child-plugin</module>
<module>child-app</module>
</modules>
<packaging>pom</packaging>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.live.hello</groupId>
<artifactId>test1-send</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>my-exe-plugin</id>
<phase>compile</phase>
<goals>
<goal>sendEmail</goal>
</goals>
<configuration>
<loginSeander>my.test#gmail.com</loginSeander>
<passwordSender>11111111</passwordSender>
<mailRecipient>mymail#gmail.com</mailRecipient>
<subject>My first messege</subject>
<text>Hello!</text>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Related
I have a Maven POM project test-module3 with two dependencies: Dependency test-module1 and dependency test-module2.
Dependency test-module2 has also test-module1 as dependency with scope set to compile, but it does not have the Maven Shade Plugin or the Maven Assembly Plugin configured.
Now I want to build dependency test-module2 using test-module3. So I configure the Maven Assemby Plugin. That works great. But dependency test-module1 is missing in dependency test-module2.
How can I configure the Maven Assemby Plugin or any other plugin of test-module3 so, that it shades test-module1 into test-module2?
Here are my POMs:
<?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>test</groupId>
<artifactId>test-project</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>test-distribution</artifactId>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>test</groupId>
<version>${project.version}</version>
<artifactId>test-module1</artifactId>
</dependency>
<dependency>
<groupId>test</groupId>
<version>${project.version}</version>
<artifactId>test-module2</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/assembly/distribution.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
distribution.xml:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>distribution</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
</dependencySet>
</dependencySets>
</assembly>
POM of test-module1:
<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>test</groupId>
<artifactId>test-project</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>test-module1</artifactId>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
POM of test-module2:
<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>test</groupId>
<artifactId>test-project</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>test-module2</artifactId>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>test-module1</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
My goal is to put test-module1 in the ZIP folder and test-module2 in the ZIP folder, but test-module2 should also contain test-module1.
I have a spring boot multi-module project in IntelliJ, The problem is, when I run the project in IntelliJ, it builds and works as expected but when I try a maven package, I get this error:
The POM for ng.biosec:enrollment_ws:jar:0.0.1-SNAPSHOT is missing, no
dependency information available and The POM for
ng.biosec:abis_module:jar:0.0.1-SNAPSHOT is missing, no dependency
information available
and then the process fails.
Here is my pom.xml for the the two modules and the parent:
enrollment_ws.xml pom
<?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">
<parent>
<artifactId>integron</artifactId>
<groupId>ng.biosec</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>enrollment_ws</artifactId>
<packaging>jar</packaging>
<dependencies>
</dependencies>
</project>
This is the abis_module.xml pom file:
<?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">
<parent>
<artifactId>integron</artifactId>
<groupId>ng.biosec</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>abis_module</artifactId>
<packaging>jar</packaging>
</project>
This is the cpm.xml pom file that depends on the modules that contain the pom files mentioned above:
<?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">
<parent>
<artifactId>integron</artifactId>
<groupId>ng.biosec</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cpm</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>ng.biosec</groupId>
<artifactId>enrollment_ws</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ng.biosec</groupId>
<artifactId>abis_module</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
</dependency>
</dependencies>
</project>
The cpm module contains the Spring boot application class. This is the Spring Application class:
#SpringBootApplication
#EnableScheduling
#EnableJpaRepositories(basePackages = {"integron"})
#ComponentScan(basePackages = {"integron"})
#EntityScan(basePackages = {"integron"})
public class BioConnectApplication {
public static void main(String[] args) {
SpringApplication.run(BioConnectApplication.class, args);
}
}
Also, this is the parent pom file:
<?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>
<modules>
<module>enrollment_ws</module>
<module>cpm</module>
<module>verification</module>
<module>abis_module</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from integron.repository -->
</parent>
<groupId>ng.biosec</groupId>
<artifactId>integron</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>integron</name>
<description>Bio Connect Project</description>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- tag::wsdl[] -->
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>integron.client</generatePackage>
<schemas>
<schema>
<url>********?wsdl</url>
</schema>
</schemas>
</configuration>
</plugin>
<!-- end::wsdl[] -->
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Also:
I replaced the link to the WSDL file for security reason, but the maven project also does not generate classes from the WSDL. Any help with that will be greatly appreciated.
You should remove the <parent> element declaration from your integron module descriptor and move it to the sub-modules.
The spring-boot-maven-plugin should only be declared within the module holding your Spring Boot application i.e. the cpm module.
Here down how the integron project descriptor should be:
<?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>
<modules>
<module>enrollment_ws</module>
<module>cpm</module>
<module>verification</module>
<module>abis_module</module>
</modules>
<groupId>ng.biosec</groupId>
<artifactId>integron</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>integron</name>
<description>Bio Connect Project</description>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<!-- tag::wsdl[] -->
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>integron.client</generatePackage>
<schemas>
<schema>
<url>********?wsdl</url>
</schema>
</schemas>
</configuration>
</plugin>
<!-- end::wsdl[] -->
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
The cpm module descriptor should be as follows:
<?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">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from integron.repository -->
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cpm</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>ng.biosec</groupId>
<artifactId>enrollment_ws</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ng.biosec</groupId>
<artifactId>abis_module</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</project>
Concerning the wsdl generated files, I guess they are getting generated but not packaged as the parent module packaging is set to be as pom.
I have the following hierarchy:
my-app
\__ pom.xml
\__ jar-module
\__ pom.xml
\__ webapp-module
\__ pom.xml
\__ core-module
\__ pom.xml
Where core-module acts as a library providing common code for webapp-module and jar-module.
webapp-module works just fine, it's generating a war as expected and the code from core-module is being used.
The problem is with jar-module. I have no idea why, but jar-module isn't outputting a jar, even when I select to run (in IntelliJ IDEA) a simple main with a println() it does run, but there's no jar on the target folder.
How can I solve this and make the jar-module output a jar?
I am not very experienced with Maven, my goal is to be able to use the same Jersey code on a local Glassfish and in a jar to be deployed at AWS Lambda Serverless Java Container so I can easily test it locally before deployment.
I would appreciate any corrections on my hierarchy and on pom errors as well.
my-app pom.xml has a packaging of pom, but core-module and jar-module have a packaging of jar and webapp-module has a packaging of war.
here are the POMs:
my-app POM:
<?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>
<groupId>com.example.myapp</groupId>
<artifactId>myapp</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>core-module</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
core-module POM:
(I also tried it with <packaging>pom</packaging> and no jar skip properties, it didn't work)
<?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>
<artifactId>myapp</artifactId>
<groupId>com.example.myapp</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>webservice-core</artifactId>
<packaging>jar</packaging>
<modules>
<module>../jar-module</module>
<module>../webapp-module</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.deploy.skip>true</maven.deploy.skip>
<jar.skipIfEmpty>true</jar.skipIfEmpty>
<maven.install.skip>true</maven.install.skip>
<javax-ws-rs-version.version>2.1</javax-ws-rs-version.version>
<jersey.version>2.26</jersey.version>
</properties>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${javax-ws-rs-version.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey.version}</version>
</dependency>
</dependencies>
</project>
webapp-module POM:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>core-module</artifactId>
<groupId>com.example.myapp</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>webapp-module</artifactId>
<packaging>war</packaging>
<name>webapp Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<jersey.version>2.26</jersey.version>
</properties>
<dependencies>
<dependency>
<artifactId>core-module</artifactId>
<groupId>com.example.myapp</groupId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>webapp</finalName>
</build>
</project>
jar-module POM:
<?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>
<artifactId>core-module</artifactId>
<groupId>com.example.myapp</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>jar-module</artifactId>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<jersey.version>2.26</jersey.version>
<maven-shade-plugin.version>3.1.0</maven-shade-plugin.version>
</properties>
<dependencies>
<dependency>
<artifactId>core-module</artifactId>
<groupId>com.example.myapp</groupId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.amazonaws.serverless</groupId>
<artifactId>aws-serverless-java-container-jersey</artifactId>
<version>0.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<configuration> <createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
my-app is your parent module and rest are child so provide a dependencies order in parent project pom so that when you build the project ,maven will provide the dependencies as you provided in parent module.
<modules>
<module>core-module</module>
</modules>
Provide the proper ordering like parent and child modules to understand the maven for building.
my-app
<modules>
<module>core-module</module>
<module>jar-module</module>
<module>web-module</module>
</modules>
core-module
no <modules>
This is a clean hierarchy, mirrored by the directory hierarchy.
There is a difference between modules and there container and the parent relation, and other subtleties. So maybe this helps.
This application was built 15 years ago, I guess. The client has sought an upgrade/modification of this app, which I am not aware of.
I have built some POM.xml scripts. When I tried to upload it in development server, it was expecting a .WAR file inside the .EAR that I had uploaded.
Here is my pom.xml script. Please suggest some modifications.
<groupId>itaras</groupId>
<artifactId>itaras</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>ear</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>1.0</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<finalName>MyEarFile</finalName>
<version>5</version>
<generatedDescriptorLocation>$D:/itaras/ITARAS_Branch_3Aug2017/itaras/WebContent</generatedDescriptorLocation>
<modules>
<webModule>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<uri>appITARAS.war</uri>
<bundleFileName>appITARAS.war</bundleFileName>
<contextRoot>/ITARAS</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
You need a parent pom 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>
<groupId>itaras</groupId>
<artifactId>itaras</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>itaras-ear</module>
<module>itaras-war</module>
</modules>
</project>
Then you will have a war project which is a child/module of the parent. This will be your existing project like:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>itaras</groupId>
<artifactId>itaras</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>itaras-war</artifactId>
<packaging>war</packaging>
.....
Then you will have an ear project which will include the war project as a dependency, something like:
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>itaras</groupId>
<artifactId>itaras</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>itaras-ear</artifactId>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>itaras</groupId>
<artifactId>itaras-war</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
I followed the sample Git setup here: https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-jsp.
When I load the home page it displays resource could not be found. Even when I've cross-checked my configuration and the only difference between the two projects is that one is multi-module, while the other is single module.
And it worked, but for my multi-module maven project the same configuration seems to not be working... is there any explanation to this? I'm also kind of new to maven so I'm assuming it has something to do with the way I have my maven setup configured. The link to my GitHub repo is: https://github.com/diljotr/storm.net.
Relevant links to look at are:
https://github.com/diljotr/storm.net/blob/master/storm.net.app/src/main/java/storm/net/Application.java
https://github.com/diljotr/storm.net/blob/master/storm.net.web/src/main/java/storm/net/controller/HomeController.java
https://github.com/diljotr/storm.net/blob/master/storm.net.web/src/main/java/storm/net/WebApplication.java
Setup outlined below
Parent POM:
<?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>
<groupId>storm.net</groupId>
<artifactId>storm.net</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.1.RELEASE</version>
</parent>
<modules>
<module>storm.net.api</module>
<module>storm.net.core</module>
<module>storm.net.web</module>
<module>storm.net.app</module>
</modules>
<properties>
<spring.version>4.0.3.RELEASE</spring.version>
<tomcat.version>7.0.53</tomcat.version>
<!-- Spring Boot build configuration -->
<java.version>1.7</java.version>
<start-class>storm.net.Application</start-class>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</plugin>
</plugins>
</build>
</project>
Web Child POM:
<?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">
<parent>
<artifactId>storm.net</artifactId>
<groupId>storm.net</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>storm.net.web</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/webapp</directory>
</resource>
</resources>
</build>
</project>
App POM that wraps the entire library together
<?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">
<parent>
<artifactId>storm.net</artifactId>
<groupId>storm.net</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>storm.net.app</artifactId>
<dependencies>
<dependency>
<groupId>storm.net</groupId>
<artifactId>storm.net.core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>storm.net</groupId>
<artifactId>storm.net.web</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Follow below Configuration :
In Intellij:
Go to Run Menu -> Edit Configuration -> Working directory: $MODULE_WORKING_DIR$
spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp