I have configure Maven Multimodule project and when i am doing
mvn clean install
It is Creating War and Jar files for both the modules in the parent project and when i am deploying war file in Tomcat6 it is working fine.
But when i am trying to run the web module from inside eclipse .
Right Click on project->Run on Server ->Selected Tomcat as a Server
Then Project not working .
The Web Module is depended on the java project which is also a part of Multimodule project so i added dependency of this(Java) project into my web project but in web project Java build path not containing this dependency .Can anyone know how can i resolve this issue with eclipse?
As i saw in eclipse's
workspace_maven.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\web\WEB-INF\lib
i did not found the Java project here .But when i am doing
mvn clean install
and deploying that war in Tomcat the /WEB-INF/lib directory containing my Java Project jar file.
My Web Module Pom.xml file...
<?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>org.test</groupId>
<artifactId>demo_parent</artifactId>
<version>1.0.0</version>
</parent>
<groupId>org.csdc</groupId>
<artifactId>demo-web</artifactId>
<version>7.0.0</version>
<packaging>war</packaging>
<name> web Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.test</groupId>
<artifactId>core-java</artifactId>
<version>5.0.0</version>
</dependency>
</dependencies>
<build>
<finalName>amanda-web</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</build>
</project>
And my parent pom.xml 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>
<groupId>org.test</groupId>
<artifactId>demo_parent</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<modules>
<module>demo-web</module>
<module>core-java</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<properties>
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
</properties>
</project>
*Note:-*I have removed repository and dependency from parent pom.xml to make pom short.
You should need the apache maven plugin
The goal should be like tomcat:run
It will download the new instance of tomcat in your target folder and deploy your war on that tomcat.
You can set all the setting for that tomcat or can refer the setting XML in the configuration tag of the plugin.
You can run it as debug mode and all the changes can be seen on the fly. (Java, JSP files only. no XML and properties)
for your help I am adding a code that would help you in running the tomcat server and deploy the WAR when you install the web module.
The application will be installed in tomcat 5 and on the root context.
You can access it on URL: http://localhost:8080/
<project>
...
<build>
<finalName>myWAR</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<path>/</path>
</configuration>
<executions>
<execution>
<id>RUN_TOMCAT</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<inherited>false</inherited>
<configuration>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Related
I got a project which consists of two modules.
The first one is Spring Boot REST Web Service
And the second one is the code that should work with this service.
The issue: I need to start Web Service from another module from the code.
Of course, the best option here is to deploy Service to some remote host, but what are the options if I want to launch Service on the local machine?
The first idea was packaging Service module, then copying jar to the second module using maven-dependency-plugin and launching it as:
Runtime.getRuntime().exec("java -jar my-rest-service.jar");
Can I start Spring Boot app right from another module? Call Application.main() method or something?
You can build and install first module into your local maven repository (.m2 folder by default) as the jar library. Then you can use this library in your second module as the maven dependency.
After that you can start your application (second module) as usually spring-boot starts - with the main method.
Example:
First module - library:
<?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>
<url>https://example.com/module1</url>
<groupId>com.example</groupId>
<artifactId>module1</artifactId>
<name>module1</name>
<version>1.0.0</version>
<packaging>jar</packaging>
<properties>
<java.version>12</java.version>
</properties>
<build>
<finalName>module1</finalName>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Second module - application:
<?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>
<url>https://example.com/module2</url>
<groupId>com.example</groupId>
<artifactId>module2</artifactId>
<name>module2</name>
<version>1.0.0</version>
<packaging>jar</packaging>
<!--packaging>war</packaging-->
<properties>
<java.version>12</java.version>
</properties>
<build>
<finalName>module2</finalName>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- com.example -->
<dependency>
<groupId>com.example</groupId>
<artifactId>module1</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
The Spring Boot Maven plugins package our application as executable JARs – such a file can't be used in another project since class files are put into BOOT-INF/classes.
In order to share classes with another project, the best approach to take is to create a separate jar containing shared classes, then make it a dependency of all modules that rely on them.
So in your spring boot module, you need to add classifier like:
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>
and of course, you need to add your spring boot module dependency in your pom where you want to use then you should be able to use Application.java.
Please check here: Using a Spring Boot Application as a Dependency.
My goal is to package an application into a modular runtime image bundled with a custom JRE, using jlink. My app is a simple "hello world" Java Standard Edition app, with a dependency to Guava. I use the JDK 11.
Basically I try to reproduce this tutorial by Baeldung, but with NetBeans, Maven to manage the dependencies and the Maven Compiler Plugin version 3.8.1 for the build with the module system.
The directory structure:
The module-info.java file:
module TestwithJLink {
requires guava;
exports net.clementlevallois.testwithjlink;
}
Controller.java:
package net.clementlevallois.testwithjlink;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.Multiset;
public class Controller {
/**
* #param args the command line arguments
*/
public static void main(String[] args) {
Multiset<String> test = HashMultiset.create();
test.add("hello");
test.add("world");
System.out.println("test: "+ test.toString());
}
}
The pom.xml:
<?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>net.clementlevallois</groupId>
<artifactId>TestwithJLink</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<id>compile</id>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
</project>
But it creates compiled classes, no jars or modules. So I can't go further (analyze the modules of the jar with jdeps, then using jlink). I must be missing something obvious but what?
If you want to create a JAR file, then go to the root folder containing pom.xml in your terminal and type :
mvn package
This will create a JAR in target folder.
Now change your path in terminal to target folder and Run the JAR file using:
java -jar {file-name-version}.jar
Finally got it. The scenario:
working from NetBeans, with your dependencies handled by Maven
you app has a module-info.java declaration
your dependencies also have a module-info.java declaration.
You want to package your app in a way that respects the modular system. So:
have these 3 Maven plugins listed in your pom (see below). Be careful about the version numbers for the plugins! In particular, the <goal>resolve</goal> in the maven-dependency-plugin makes sure your dependencies are packaged with their module-info.java file, which is not the case otherwise! (see here).
when the compilation is done, move the jar of your app in the lib folder where all the jars of your dependencies are already located.
You can run this app directly with the run icon in NetBeans, or:
from the parent folder of your lib folder, run: java --module-path lib --module NameOfYourModule
The 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>net.clementlevallois</groupId>
<artifactId>TestwithJLink</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>net.clementlevallois</groupId>
<artifactId>utils</artifactId>
<version>1.0</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>resolve</goal>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<archive>
<manifest>
<mainClass>net.clementlevallois.testwithjlink.Controller</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<id>compile</id>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
</project>
I have created a web application based on angular 8 and spring boot. I implemented the codebase locally and it is working fine.
My Angular code(client) is running on localhost:4200 and spring boot(server) is running on localhost:8080.
Till here everything is working as expected.
Now I want to deploy this whole web application as a single bundle so that I can deploy it as a single war on tomcat.
I am creating the war file using maven.
But when I deploy this war file on tomcat and start the tomcat I am not able to see the expected login page on the browser.
Basically, I don't have much understanding of maven and was following resource available in below link on the internet to generate the war file.
https://dzone.com/articles/building-a-web-app-using-spring-boot-angular-6-and
So I am not able to figure out whether the issue is with my build or the URL through which I am trying to access the resources.
if I deploy only the UI build, then if I hit localhost:8080, I am able to see the login page.
I am having three pom files as mentioned in the tutorial.
1. parent-pom
2. server-pom
3. ui-pom
Below are my pom files
parent-pom.xml:
<?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.dzs.licenseGenerator</groupId>
<artifactId>lg-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath />
</parent>
<modules>
<module>LicenseGenerator_Backend</module>
<module>LicenseGenerator_UI</module>
</modules>
</project>
server-pom.xml
<?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>com.dzs.licenseGenerator</groupId>
<artifactId>lg-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!-- lookup parent from repository -->
</parent>
<artifactId>LicenseGenerator_Backend</artifactId>
<packaging>war</packaging>
<properties>
<java.version>1.8</java.version>
</properties>
<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>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</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>
<dependency>
<groupId>com.dzs.licenseGenerator</groupId>
<artifactId>LicenseGenerator_UI</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals><goal>copy-resources</goal></goals>
<configuration>
<tasks>
<echo>Displaying value of pom.xml element</echo>
<echo>[project.build.directory] ${project.build.directory}</echo>
<echo>[project.parent.basedir] ${project.parent.basedir}</echo>
</tasks>
<outputDirectory>${project.build.directory}/classes/resources/</outputDirectory >
<resources>
<resource>
<directory>${project.parent.basedir}/LicenseGenerator_UI/dist/lg-app/</directory >
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<packagingExcludes>WEB-INF/lib/tomcat-*.jar</packagingExcludes>
<warName>lg-app</warName>
</configuration>
</plugin>
</plugins>
</build>
</project>
UI-pom.xml
<?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>com.dzs.licenseGenerator</groupId>
<artifactId>lg-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>LicenseGenerator_UI</artifactId>
<name>LicenseGenerator_UI</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<nodeVersion>v10.16.0</nodeVersion>
<npmVersion>6.9.0</npmVersion>
<workingDirectory>src/main/web/</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
<execution>
<id>prod</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script build</arguments>
</configuration>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Just to ensure whether my code structure is correct or not I am posting a screenshot of my Project Explorer in Eclipse.
Use ng build –prod command for generating production build artifacts.
Run this command in your UI project folder.
Post generation of production build you should see new folder named ‘dist’.
You have to use Maven resource plugin to package as single jar. As i can see you already have the plugin in you pom, just verify the directory folder to pint to dist folder.
After this just run maven clean install . After running this you should see jar with both Angular 6 & Spring Boot application on the target folder.
Execute with Java –jar command to launch the application, you should see the Angular application served from static folder.
You can use frontend-maven-plugin for kicking off your frontend build. Once the frontend build is completed, it will generate the resource files in dist directory.
After that you can use the maven-resources-plugin to copy the files from dist to the required location in the target directory.
I have a main application called MainApp. This app contains a dashboard project and store project. Whenever I make change to either dashboard or store project, I had to run the maven clean install via IntelliJ for the project where I make the change. Then I go to my maven configuration for the MainApp pom.xml then run the pom.xml via clean install tomcat7:run -Pfront-end-build -U to deploy the project.
Is this the right way of doing it? I know this is a bit subjective,but I was thinking won't it be possible to just compile, build and run everything from MainApp? I noticed when I run the pom.xml in MainApp, it just gets the dependency wars ( store and dashboard ) from our Nexus repo (so I guess that war don't contain my latest changes).
MainApp
pom.xml
-----dashboard
-------pom.xml
-----store
-------pom.xml
MainApp pom.xml
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
<relativePath/>
</parent>
<groupId>com.pab</groupId>
<artifactId>MainApp</artifactId>
<version>0.0.2-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>store</module>
<module>dashboard</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
dependency....
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<webapps>
<webapp>
<contextPath>/store</contextPath>
<groupId>com.pab</groupId>
<artifactId>store</artifactId>
<version>${project.version}</version>
<type>war</type>
<asWebapp>true</asWebapp>
</webapp>
<webapp>
<contextPath>/</contextPath>
<groupId>com.pab</groupId>
<artifactId>dashboard</artifactId>
<version>${project.version}</version>
<type>war</type>
<asWebapp>true</asWebapp>
</webapp>
</webapps>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>releases</id>
<name>Releases</name>
<uniqueVersion>true</uniqueVersion>
<url>${release.repo.url}</url>
<layout>default</layout>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Snapshots</name>
<uniqueVersion>false</uniqueVersion>
<url>${snapshot.repo.url}</url>
<layout>default</layout>
</snapshotRepository>
</distributionManagement>
dashboard pom.xml
<modelVersion>4.0.0</modelVersion>
<artifactId>dashboard</artifactId>
<packaging>war</packaging>
<name>dashboard</name>
<parent>
<groupId>com.pab</groupId>
<artifactId>MainApp</artifactId>
<version>0.0.2-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<properties>
<webpack.cmd>webpack</webpack.cmd>
</properties>
<profiles>
<profile>
<id>front-end-build</id>
<build>
<plugins>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<finalName>dashboard</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
</plugins>
</pluginManagement>
</build>
</project>
store pom.xml
<modelVersion>4.0.0</modelVersion>
<artifactId>store</artifactId>
<packaging>war</packaging>
<name>store</name>
<parent>
<groupId>com.pab</groupId>
<artifactId>MainApp</artifactId>
<version>0.0.2-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<profiles>
<profile>
<id>front-end-build</id>
<build>
<plugins>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<finalName>store</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<systemProperties>
<org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING>false
</org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING>
</systemProperties>
<warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>1.4.0</version>
<configuration>
<workingDirectory>src/main/client</workingDirectory>
</configuration>
<executions>
<execution>
<id>npm</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>webpack</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>build</argument>
</arguments>
<environmentVariables>
<NODE_ENV>
production
</NODE_ENV>
</environmentVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Now, after struggling with this for quite some time. I did some more testing.
I run mvn clean install -Pfront-end-build -U via git bash in the MainApp folder, essentially this executed the pom.xml in that folder which is the parent pom.xml of the inner modules. It successfully built the inner modules store and dashboard. However what I noticed is, when i execute this command in IntelliJ: clean install -Pfront-end-build -U tomcat7:run . The inner modules are not being built. It seemed that the tomcat plugin is trying to deploy the modules immediately thus it is trying to get the war files from the repository. This is where the problem lies now. For now, what I'm doing is i build the whole project (together with the inner modules) outside intelli J then go back to intelli J and run the tomcat maven plugin (tomcat7:run) so I'll have the option to debug through the code using intelli J.
Your main pom xml has store and dashboard defined as modules so if you mvn clean install at main pom xml it should build both the projects and your changes should be reflected in new war.
<modules>
<module>store</module>
<module>dashboard</module>
</modules>
If you are running tomcat in ide like eclipse then once you build your project then it should show synchronized or needs synchronized besides tomcat server. If later then right click on tomcat server and restart tomcat server and it should synchronize i.e. redeploy wars on tomcat server.
I want to change file system of Eclipse for change "support" or "User interface" (UI) of New Dynamic WEB Project.
I have Windows 7 but I am interested also on Linux.
Should be easy change file system in Linux and not in Windows.
What do I would to change?
In Eclipse, I press NEW-> Dynamic Web Project, put the name and press Next.
We have, in default, this window:
Now I have to remove src folder and put new folders src\main\java and src\main\resource.
So I will have a folder "Source Folders" of Maven project because I will convert in it.
So the result is:
- Why not do New Maven Project so I will have these directory
java resource.
Why I not like the pom.xml of new Maven Project that is in default:
<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>
<groupId>bla</groupId>
<artifactId>bla</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>asd Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>bla</finalName>
</build>
</project>
Miss the plugin of maven:
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
If I do, from project Dynamic WEB project and will convert to Maven Project. I will have this pom.xml that is generated from Eclipse:
<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>HibernateExample</groupId>
<artifactId>HibernateExample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>HibernateExample</name>
<url>http://maven.apache.org</url>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
For me like too the second pom.xml and not get error of miss plugin maven.
So today I've got an idea:
Why not change the program files (say inside folder Eclipse) and change line of folder " Source
Resource"?
So I will have the new default windows (see second image) in every time when I create Dynamic WEB Project.
I hope the title is correct.