Maven deployment - java

mvn clean deploy -P PROD
What does this code do?
mvn jetty:run
I have a war file, do i need to run this deploy code too... i am bit confused.

I'd advise you to read the Deploy plugin documentation, ditto for the Jetty one.
From what I can see, mvn clean deploy cleans your project (suppresses compiled files), and then compiles and deploy it. mvn jetty:run launches the jetty server.
If you're completely new to Maven, it's a build system, to help you manage your dependencies and your application lifecycle. You can read more about it on the Maven site.

clean deploy
I suggest you read up on the Maven Build Lifecycle to get full details on these.
-P PROD
This runs the build under the PROD profile; presumably it is your production build.

Related

Installing maven depencies from pom.xml in docker

I am trying to run a spring-boot maven project inside a docker environment. So the setup is as follows:
Docker is set up and installs Java, etc. (done only once)
App is run (can be any number of times)
What I am experiencing
Every time I run the spring-boot project by mvn spring-boot:run, it installs all the required libraries (every time I run the project) from the pom.xml (Java, Maven, etc. are preinstalled from the docker) and then runs the project.
What I am trying to do
This process of reinstalling every time is redundant and time-consuming, so I want to delegate this installation thing to the docker as well. Ideally, using the pom.xml to do the installations, though alternative ways are also welcome.
What I have tried so far
Install npm using a good tutorial, but it fails in Docker as we can't restart the terminal during docker build, while source ~/.bash_profile doesn't seem to work either.
Tried to build that project directly in docker (by RUN mvn clean install --fail-never) and copying both npm and node folders to the directory where I run the app. But it doesn't seem to work either as it's installing them every time without any change.
Can anyone please help me there? This problem has stuck the project. Thanks a lot!
From your question I understand that, in the Dockerfile you just install java, maven, etc. but does not build your project using mvn clean package install before executing mvn spring-boot:run (and that is redundant as well because mvn spring-boot:run does the build for you before staring the application).
You cannot skip installing maven dependency while running on containers as they are spun as they run. So it will be installed either while you call mvn clean install or mvn spring-boot:run.
What the max you can do is, using your devops pipeline, build the jar previously and in the Dockerfile just copy the build jar and execute.
Example Dockerfile in this case:
FROM openjdk:8-jdk-alpine
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
Here the previously build artifact is already available at target/

Difference between mvn appengine:update and mvn appengine:deploy in Google App Engine

What is the difference between
mvn appengine:update
and
mvn appengine:deploy in Google App Engine.
It depends on the configuration you're using for your project. The old AppEngine plugin for Maven only supports mvn appengine:update as far as I know. The newer one supports mvn appengine:deploy.
By the way, the very latest one was renamed to mvn gcloud:deploy, so that might add to the confusion.
According to the google app engine reference:
For mvn appengine:deploy
The appengine:deploy goal and all other goals in the App Engine Maven
plugin have associated parameters that you can use. For a complete
list of goals and parameters, refer to App Engine Maven Plugin Goals
and Parameters.
The complete reference here
For mvn appengine:update :
To deploy your app with Maven, run the following command from your
project's top level directory, where the pom.xml file is located, for
example:
mvn appengine:update
The complete reference here

How to run the downloaded project through eclipse

I am referring "http://krams915.blogspot.in/2011/01/spring-mvc-3-hibernate-annotations.html" blog and at end of the blog there is source code in zip folder i have downloaded but i dont know how to run in Eclipse,
at the last on blog they have mention
You can run the project directly using an embedded server via Maven.
For Tomcat: mvn tomcat:run
For Jetty: mvn jetty:run
I dont know how use this steps.please help me how to run this project,
I am using tomcat as my server,
Thanks,
Basically you need to do two things:
Install maven plugin in eclipse.
Add a tomcat server instance in eclipse.
This link should guide you to achieve that:
http://www.mulesoft.com/tomcat-maven
Install Maven
go through command line to your project folder
call mvn tomcat:run or mvn jetty:run
1.Install Maven
2.set system enivorment
3.go through command line to your project folder(where the pom.xml is)
4.call mvn tomcat:run or mvn jetty:run
Download Spring Source Tool suite which comes along with maven. It maked things little easier for you. You can directly run maven projects from the IDE itself.

Can I build multiple projects with Maven and then run Jetty through m2eclipse?

I have a multi-module project which has a war and multiple jar dependencies. I'd like to be able to build multiple projects (the dependencies) and then launch the war in jetty with a single command. Is this possible? I'd normally make a script to do this, e.g.
mvn clean install
cd project-web/
mvn jetty:run
cd ..
However, this loses the Debug functionality from Eclipse. Is there a way to do this in m2eclipse?
You are gonna want to run configure the MAVEN_OPTS to allow an external debugger and connect to it from eclipse as a Remote Java Application:
http://docs.codehaus.org/display/JETTY/Debugging+with+the+Maven+Jetty+Plugin+inside+Eclipse

maven deploy goal failing

I am using eclipse with maven2 plugin.
When doing a Run-As -> build with a goal of 'deploy' I am getting this error:
Error message:org.codehaus.plexus.component.configurator.ComponentConfigurationException: Class 'org.apache.maven.artifact.repository.ArtifactRepository' cannot be instantiated
I'm not sure I even need to do a 'deploy', I have another build that does a 'compile' goal, and from what I have learned doing a Run-As -> Run on Server (tomcat) is enough to deploy my application locally to tomcat.
Do I need run this build 'deploy' goal to run locally, should I just delete it and use 'run on server'?
Running mvn deploy won't "deploy your application on Tomcat", deploy is something different here, deploy is a phase done in an integration or release environment and copies the final package to the remote repository for sharing with other developers and projects.
In other words, unless you are dealing with a remote repository to distribute your application (and this requires to configure a valid <distributionManagement/> section in your POM), just forget about deploy for now, this is not what you think it is :)
So, to run your application and "deploy it on Tomcat" from Eclipse, use Run As > Run on Server. If you want to run it from outside Eclipse, you can use mvn tomcat:run but this isn't really appropriate here (this goal is an handy way to run a webapp without importing it in a IDE). And if really you want to deploy your application on Tomcat from the command line, the Maven Tomcat plugin supports many methods for Deployment. But again, I don't think that this is what you're looking for for now.

Categories

Resources