Maven plugin for clean the tomcat target folder and war file - java

I want to know how can i remove the target folder and war file which created within webapps folder when i deploy the project.
I'm using eclipse IDE for the deploy project. I want to what is the maven plugin for this goal.
But if I used terminal for deploy the project i can used. But sometimes this command also unable to clean the webapps folder.
mvn clean compile war:war

Do you get an error message when using mvn clean ?
Do you have open files which are located in the structure under target? This prevents the target folder from being deleted.

Related

how to connect java library to project to test the library

So I need to connect a library to my repo in IntelliJ, so I can test the library as it interacts with my main project. And I got this command from a member on my team: "So you need to change .java files in entity manager (which is the library) repo and do mvn clean package to generate the jar file locally, the use that jar in your project repo.
Then create dummy folder in your project with the same package name and copy those .java files from entity manager."
What does change the java files mean? What about "use that jar"? I'm so confused.
Use "mvn install" instead of package. This puts the library into your local .m2 repo and makes it available to your project in idea
If you do mvn clean package it produces a .jar file in target/ folder. Use that dependency to your project if they both share a common parent pom.xml
If you do mvn clean install it produces the jar file in target/ folder + copies the .jar file to your local m2 folder. That way you can use that .jar file to any project locally. Just use the with matching version, artifact and groupId whereever you need to use that jar file.
For both options above, you need to define sth like below in your pom.xml
<dependency>
<groupId>com.my.library</groupId>
<artifactId>mylib-artifact</artifactId>
<version>1.VERSION</version>
</dependency>
Not recommended:
You can also put the .jar file to your project (without doing mvn clean install) See: http://blog.gtiwari333.com/2016/12/maven-use-local-jar-without-installing.html
Or manually add the .jar to your project as project dependency using your IDE's project configuration

Export jar with spring boot

I need to export executable jar from intellij spring boot project. its basic rest only. How can it possible. I have created the artifact jar and when i try to run it with java -jar xxx.jar it returns manifest file not found error.
Generally you have this error when you generate the JAR using the IDE directly (export option of Eclipse for example).
You can either use the Maven goals clean install or clean package to compile and generate the JAR in your target folder and/or local repository.
package - take the compiled code and package it in its distributable
format, such as a JAR.
install - install the package into the local repository, for use as a
dependency in other projects locally
The install will execute the package one step before install it on your local repository.
Maven Lifecycle Documentation
If you have installed maven, On the terminal of Intellij Idea use following code.
mvn clean package
Your Jar will be saved inside "target" folder inside the project directory

Deploying Maven project tusing eclipse jboss tools

I'm trying to get my maven project deployed to Jboss AS 7.1 using the jbos tools plugin version 4.3.1.FINAL.
My project setup is
parentPom
common.jar
util.jar
mywebapp.war
When I run mvn clean install form both eclipse and command line the resulting target folder is the same atleast for the mywebapp.war and /mywebapp (folder)
If i copy either the folder or war file from the target folder directly into the servers /standalone/deployments directory. The application starts up without a problem.
However if I go to my server setup in eclipse which is pointing to the same base and do Add/Remove -> select mywebapp -> run
The problem is this doesnt copy all the files over to the server becasue when i run a diff I see a whole load of files missing. Consequently the build fails saying it canot load some annotation, presumably this is because some of the files are missing.
Ideally I wouldn't want to copy the war or folder manually and would love to be able to edit jsp/css/javascript files etc without having to go through this laborious task.

Intellij + maven jetty plugin vs eclipse + jetty hot deploy?

I have eclipse and intellij from the same workspace because both replies on pom.xml file. I notice something different. In eclipse, when I setup Jetty Webapp under Run Configurations and run jetty it looks at /classes folder for any changes if some of the projects are open (I have about 15 projects, some of them closed some of them open). If some of the projects are not open it will look at jar files from .m2 folder which is fine. So, when I change something I could just compile the file and see the changes without restarting the server.
However, in Intellij CE when I run jetty:run from maven it only looks at .m2 folder for the jar files, so I had to mvn clean install every time to update .m2 folder and restart the server. How could I achieve the same thing in IntelliJ? So, when I change something in Java classes I don't have to restart the server?

Eclipse and SubClipse: How to deploy my own package with svn to a TomCat server?

I'm using SubClipse for Eclipse for my project.
And in this project I've added my own package "com.mytestpkg.www"
I then use TortoiseSVN to deploy my project on the TomCat server where the project is running, because i the easily can update the site with "SVN Update".
But using this method I always have to manually update my package by copying it from my Eclipse workspace build path to the WEB-INF folder classes/com/mytestpkg/www.
Is there a way to make Subclipse/SVN update this file directly with the other files?
Why don't you do this a more conventional way; e.g.
get Eclipse to create and deploy a WAR file
use Ant or Maven to build the WAR file and deploy it by hand. (The Maven way of building WAR files is really slick!)
Doing a checkout into a Tomcat server's webapps directory is ... weird. And you've got the problem of stopping the world seeing the .svn directories.

Categories