I have a maven based spring mvc project. I can build that project and run it via tomcat manually like this
mvn package -Dbuild.name=App1
mvn package -Dbuild.name=App2
mvn package -Dbuild.name=App3
and then can copy those generate war files App1.war, App2.war and App3.war into my tomcat folder and start it. It works fine.
Question is how to do the same using intelliJ IDEA?
I generated war files one by one by using Maven Project window and creating custom value for package goal. It generates .war files in target folder. But when I run it in Tomcat of intelliJ it only runs the application at root "/" address. For other addresses
/App2 -> 404
/App3 -> 404
You can have multiple artifacts created in IntelliJ IDEA and configured for deployment at the same time in the application server Run/Debug configuration, Deployment tab under different contexts.
Note that Deployment tab has a configuration to perform the deployment from the External source where you can specify the location of the war produced by Maven if you don't want to use artifacts for some reason.
Related
I've installed the spring example RESTful Web Service. And I have it building fine in IntelliJ. But how do I get IntelliJ to create gs-rest-service-0.1.0.jar? There are menu commands to synchronize gradle & maven, but nothing to use them to build the jar.
A standard POM/Maven-based project can be built via the console by typing:
mvn package
the maven lifecycle, by default, will place the output artifact (i.e. JAR / WAR file) under the target folder.
Alternatively, since you are using IntelliJ, you can also use the IDE to run the build for you. The simplest way is to navigate on the right side tab
mvn > your_project > lifecycles > package
the output will continue to be placed in the same target folder.
Assuming the project has a pom file. And it was mentioned building fine in the post. Assumption: STS/Eclipse users
Right click on pom file -> run as maven build. In the console it displays where the jar file is created.
Go to: project folder -> target folder -> gs-rest-service-0.1.0.jar
file
I have a Maven Dynamic web project in Spring - I can run this in eclipse with a tomcat server and serve all my code a web page via localhost.
I am looking to create an executable which can be ran locally on a machine with no internet connection and when ran will serve the web project to a specified localhost URL.
If you have included an embedded server (like tomcat) as a dependency in you POM.xml file, then you have to Right Click on your Project -> Run as -> Maven Install. This will build a Maven Executable Jar file in the target folder of your Maven Application.
Take the Jar file and Run it from command line using
java -jar <jarfilename>.jar
After building project you will have <project_name>.war file created in target folder inside the project.
You should deploy it to a J2EE application server, like: Glassfish, JBoss Wildfly, etc.
I want to deploy an application into wildfly as war packaged using maven. The challenge i am facing is , i need to create a directory in the server and add my application's property file and a log4j property file into it. This must be automated using maven build.
First i need to know if this is possible to create a folder in server which is not the project home directory, but elsewhere using maven while deploying it ?
If so , how do i create it, and how to add the property files into it which is in my project resource folder.
Note: My deployment is automated through Jenkins.
I am using Jelastic and I have an environment with a WildFly 10.1 node and a Maven 3.5.0 node. When I click "build and deploy" on the project in the Maven node my application should build and deploy a EAR file.
However, after the first time I do that, the deploy fails, and when I check the WildFly admin console there is a EAR and a WAR file. I have no idea where this WAR is coming from, and I can't find such file in the "target" folder either.
Checking the WildFly log, I see a "org.jboss.msc.service.DuplicateServiceException: Service jboss.naming.context.java.app.myapp-dev is already registered"
If I remove the war from the admin console, disable the EAR and re-enable it, the application works.
I don't know exactly how Jelastic works with maven, but I believe there is no problem with my pom.xml files.
Thanks in advance!
edit: here's the pom.xml for the project root, and the pom.xml for the inner EAR module.
Automatic build and deploy functionality in Jelastic is designed to build all the targets specified in pom.xml and deploy all the built artifacts to the app server.
If multiple targets are specified in root pom.xml of the project, all of them will be built and deployed to the app server, not only the .ear target.
Please try to deploy the subproject with the inner EAR module with the appropriate pom.xml as root project file to build and deploy only the *.ear file.
I have the following Problem:
I have a Maven MainProject with some SubProjects.
Two of this SubProjects are WebApplications. (One WebApp and one WebService)
If I build the MainProject in the command line with mvn clean package the 2 .war files are deployable in an external Apache Tomcat 6.0.
If I build the MainProject in eclipse with the m2e plugin i can also deploy the .war files into an external Tomcat.
BUT if i want to deploy the WebProjects in an Apache Tomcat in Eclipse, it doesn't boot.
The Problem is, that the file structure of the eclipse build for the internal Tomcat is different to the Maven one.
In the Maven build (console / m2e) the path is correctly from e.g. Project/src/main/java/com/... to WEB-INF/com...
The eclipse build for the internal Tomcat creates the structure like WEB-INF/main/java/com/...
So many of the .xml files which are mandatory for the Tomcat boot are not found bacause of the wrong path.
How can i tell eclipse that it should do the similar build like m2e or maven on command line so that i can use an internal tomcat in eclipse?
I am using
Eclipse Juno 4.2 or Helios 3.6
m2e - Maven Integration for Eclipse / 1.1.0.20120530-0009 / org.eclipse.m2e.feature.feature.group
Maven Integration for WTP / 0.15.2.20120306-2040 / org.maven.ide.eclipse.wtp.feature.feature.group
I fixed the problem.
The problem was the deployment assembly options in the eclipse projects.
Eclipse default option is to deploy /src to / folder.
Because of the maven structure /src/main/java/com the deployed folder also looks like /main/java/com.
I only had to change the source folder from /src to /src/main/java (the destination still remains /). If there are other necessary files i had to add them the same way, e.g. /src/main/resources.
The /src/main/webapp folder was already set correctly by eclipse to /WEB-INF