How do I run the Spring RESTful Web Service - spring

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

Related

Maven Build Scripts Found - IntelliJ - What are the build scripts, where are they cached?

So basically, as the title of the post states, I'm wondering what IntelliJ is referring to when it says that Maven build scripts were found? Are these scripts that Maven keeps cached or are they IntelliJ specific? If they are generated by Maven, where are they stored/ how can I view them if that is possible?
Thanks!
This notification is to inform you that you are working with IntelliJ IDEA project that is not linked to the external build system (Maven or Gradle).
When you open a project in IntelliJ IDEA that was not initially imported from Maven/Gradle and IDE detects pom.xml or build.gradle files in the project, it will display a notification so that you can properly import the project from the build script.
Build script in your specific case is a pom.xml file stored inside a project directory. It's recommended that you open Maven projects by importing the root pom.xml file.
When a project is not imported from the external build system, your source roots configuration may be incomplete and you may be missing the dependencies.

Spring Boot with Maven Install vs Eclipse Export WAR

I hardly use Maven.The only time for me to use it is for maintaining my web app dependencies.
Now I started to develop web app using Spring Boot. I notice when I run Maven install, a WAR file will be created in the target folder. Then I export WAR using File > Export on my STS IDE and compare the two wars. The size of the 2 files are different. How can this be ? Also, the WAR file created from Maven runs fine on standalone Tomcat 7 while the exported war from Eclipse (STS) doesn't.
What am I missing here ?
It's reasonable to assume that WTP (File > Export > Web etc) would produce a different WAR file from the maven build. Maven build may have plugins applied to the build to produce the desired WAR file. Check your POM file carefully and check if there are any maven plugins used in the build.
Now, I don't exactly know how Eclipse WTP component produces their WAR file (Export WAR file is not from STS - it's Eclipse WebToolsProject) from the project. There might be options in the export wizard to play around with or some configuration file in your project. You'd better off asking that on the Eclipse forum: https://eclipse.org/forums/index.php?t=thread&frm_id=88
Hope this helps.

How to deploy custom JavaScript rules in Sonarqube?

I recently happened to work on Sonarqube version 5.3. I installed it and the Sonar server is running fine, I even analysed some code and installed some plugins, but now I want to define some custom rules in JavaScript. I downloaded the sample code from Sonarqube website for custom rule in JS.
The downloaded folder has one pom.xml and src folder. I don't know how to deploy this custom rule, somewhere I read that I need to create .jar file and place it in "extension/plugins" folder. I am stuck here: I don't know how to generate .jar file.
You've downloaded the source code, which is a Maven Project, now you should build the plugin with Maven (mvn).
See SonarQube documentation on Building Plugins.
When you download the "javascript custom rule" project from https://github.com/SonarSource/sonar-examples/tree/master/plugins/javascript-custom-rules
You can see that it's a Maven project as it has pom.xml
Now you have 2 option to create .jar out of this project.
Option#1: Open this project in Eclipse and do "Run==> maven Clean" and then "Run==> maven install"
It will generate a .jar for you which you can see in Eclipse console.
Option#2: Open Linux terminal or windows cmd, ensure that you have maven installed. Go to the project path where pom.xml is there and invoke command: "mvn clean install"
It will generate a .jar for you which you can see in console.
Thanks !

run maven project with eclipse

I'm new to maven and eclipse. I added m2e-plugin in eclipse and I imported an example of a maven project that I've found in the net.
My problem is when I try to run the project in eclipse using the Run as item menu, I don't find the maven package menu as I learned in the different tutorials.
Is it a problem of installation?
Ok, lets go through this step by step to make sure you have everything you need to get going.
First of all make sure that you have Maven installed (and lets assume you have Java already). You can download it from http://maven.apache.org/download.cgi and installation instructions for Fedora (which I assume is what you are using from your tag) are further down the page.
To test that Maven is correctly installed and working type mvn --help in to the terminal. Eclipse and m2e pretty much just hop on to the terminal for everything Maven related so make sure this is working before proceeding.
Next download an appropriate version of Eclipse. For the sake of this example I've downloaded the Kepler version of the Java EE IDE. In this version of Eclipse m2e comes bundled and to check this you can go to Help > About Eclipse > Installation Details and on the plug-ins tab you should see the m2e connectors.
Now you can import your Maven project in to Eclipse. To do this go to File > Import and then choose Existing Maven Projects under the Maven section. Choose the directory with the example project that you've downloaded and then Finish.
Now, ensure that you have some file inside your example Maven project opened and when you go to Run As... you should now be able to see the maven options. Go to Run As > Maven build... and all you need to do is place the word package in the Goals field and you're ready to roll.
Convert your project to a maven project if you haven't done yet by right clicking on your project in the Eclipse Project/Package explorer. Then follow:
Configure -> Convert to Maven Project
After that you can just right click again on the project Run as and you will see all Maven possibilities to execute your project build/install/clean etc.

deploying multple war files using intelliJ IDEA

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.

Resources