spring mvc test using eclipse and maven2 - java

So I created a simple web app using maven, the pom.xml is setup in Eclipse just fine.
I added apache commons, spring 3.0 as a dependancy.
I created a test controller using annotations, and a jsp file.
In eclipse, I only see a Run option, and no build option. With maven2 pom.xml setup etc., is just clicking on Run enough to build the project?

If you have m2eclipse installed and if your project is recognized as a "Maven project", then you should have more entries in the Run As... and Debug As... menus allowing to run a Maven build within Eclipse:
(source: theserverside.com)
And if you don't have m2eclipse installed, either install it(!) or launch Maven as External Tools (but this won't provide "real" integration).

Related

How to run maven project on jetty in Intellij as in Eclipse?

Maven project (project name: english) [vaadin, jetty] runs in Eclipse without any problem. How to run/configure exactly the same project in Intellij? Run/Apply options are not available after below configuration. In Eclipse I set, Base directory [${workspace_loc:/english}], Goals [jetty:run], JRE, Source (english project). How to set it in Intellij?
eclipse1
eclipse2
eclipse3
intellij1
intellij2
First things first, you need to add jetty plugin for maven as a dependency, if you don't have it already in your pom.xml. More about jetty maven plugin can be found here
If you were running the project via embedded jetty plugin in eclipse, same pom.xml configuration should run successfully run when you issue same command in intellij IDE.
If there are any issues on your build, try with a "clean rebuild" before you start doing anything else. You can do that via the following command in your terminal:
mvn clean install jetty:run
You will need access your console (terminal), i.e. via Alt + F12 keys. You also need to be in the same directory that you have the pom.xml in your project.
The command will basically clean up (i.e. delete) previously build project and do a fresh rebuild of your project, then run it via embedded jetty plugin.
Be sure to read a brief introduction to maven commands: Maven in 5 minutes if needed.
After you successfully issued this command for the first time, I think you can can also issue jetty:run via View -> Tool windows -> maven project.
You can usually access it also on your right side of intellij IDE (the "m" icon, maven projects).

Spring project with eclipse

I'm using Spring Tool Suite (STS) [Version: 3.1.0.RELEASE] to make Spring project using Spring 3 + Hibernate. I want to use eclipse for that.
What to do? What eclipse plugin should be installed in eclipse for making Spring project?
By Eclipse Marketplace:
Open eclipse --> Help --> Eclipse Marketplace
Search by keyword "STS"
Click Install button on "Spring Tool Suite (STS) for Eclipse Indigo (3.7)" section
Follow the eclipse instruction
The following is the Classic way:
In Eclipse IDE: Click “Help” -> “Install New Software…”. Type “http://springide.org/updatesite” to access the Spring IDE update site.
Select all the Spring IDE features you want to install. And wait as it needs - that's it
If you already using STS you can easily create Spring projects - no additional plugins needed.
STS is Eclipse with Spring plugins added - don't waste your time doing it manually.
In the main menu select File > New > Other...
Type "Spring" in the search bar.
Select "Spring Template Project", click "Next"
Open "Persistence" node and select "Simple Spring Hibernate Utility Project" and follow the wizard.
After wizard is done you are going to have simple Spring/Hibernate project in your workspace.
UPDATE:
Spring projects are simple java projects and be created easily using just Maven. Add m2e plugin if you don't have it yet and add required spring jars as dependencies in your pom.xml file.
M2E comes preinstalled with STS, but can be installed into any Eclipse installation.
More information about using m2e can be found at http://www.sonatype.org/m2eclipse

How do I set up a new Java project with Eclipse, Maven, Grails and git?

I'm new to Grails development and would like to set up a new project, so I can use Eclipse as IDE and build it on my CI (Jenkins) with Maven. This is my environment:
Java 1.6.0
Grails 2.1.0
Maven 2.2.1
Eclipse Juno with the m2e and egit plugins
I used the following commands from
http://grails.org/doc/latest/guide/commandLine.html#antAndMaven:
mvn archetype:generate -DarchetypeGroupId=org.grails \
-DarchetypeArtifactId=grails-maven-archetype -DarchetypeVersion=2.1.0 \
-DgroupId=com.company.dep -DartifactId=project
mvn initialize
But after importing it as a maven project in Eclipse, there were erros about slf4j and com.sun.tools not found and lifecycle phases not mapped.
What steps are necessary to get this running in Eclipse?
Plugins, Plugins, Plugins... you can add the maven plugin / Grails plugin for eclipse and just build a new project.
Select the option to create a maven project (it will auto generate the pom files for you) then you can add Grails to it...
Similarly you can start a new grails project and then add maven to it. It will download all the dependencies automatically.
Most plugins are free to download from : http://marketplace.eclipse.org
com.sun.tools error is commonly caused when Eclipse uses a JRE and not JDK.
Grails has its own mechanism for creating projects, use it. Since Grails 2.1 you can generate the maven stuff afterwards.
You can follow this proces:
Get STS - Springsrouce Tool Suite (actual 3.0), based on Eclipse
Install the Grails plugin into STS.
Get the Grails FW, unpack it and configure the path to it in STS.
Create new project via Grails command: grails create-app
Import it into Git.
About maven integration, there is a good article:
http://www.znetdevelopment.com/blogs/2012/07/11/grails-2-1-and-maven-integration-simple-project/

Eclipse Marketplace - Maven Integration

I am in Eclipse Indigo and trying to install Maven Support for eclipse. I search Eclipse Marketplace with "maven" and found there are two entries:
Maven Integration for Eclipse WTP.
Maven Integration for Eclipse.
Now I am confused to choose them.
I am developing web application. So what is the entry I should go for?
Install them both. The first is specifically designed to integrate with WTP, the second one is general Maven integration in Eclipse.
Have you tried to just use Maven? With Indigo, m2e is already integrated. If you look at eclipse.org, you will find there the following features integrated:
If you open the preferences in Eclipse (Windows > Preferences), you will find there the Maven configuration for Eclipse:
You have to configure there, where your Maven installation lives, and can start to use Maven inside Eclipse.

How can I run a GWT app from gwt-maven-plugin without any browser plugins?

For a GWT application which I build with the GWT Maven Plugin (gwt-maven-plugin), I can run the GWT Development environment with
mvn compile war:exploded gwt:run
and then launch a browser. This requires that the browser provides the GWT Developer Plugin. (Firefox 6 for example does not yet support the GWT Plugin).
Does the GWT Maven Plugin also allow to simply run the included Jetty container with the GWT application, without a development mode?
After configuring gwt-maven plugin you could simply run the following.
mvn jetty:run-war
After gwt compilation the resulting war will be placed in jetty and started via Maven Jetty Plugin.
The only way to run the project without plugin is to compile it and run on a server. If you are using Netbeans just hit run. The IDE will compile and deploy project on a server. In other way just compile it with the following command (you can omit tests and reports):
mvn clean:clean resources:resources compiler:compile war:exploded resources:testResources compiler:testCompile surefire:test gwt:compile war:war
After this you 've got ready to deploy war file. To deploy it to the Glassfish there are now basically three options:
Maven GlassFish Plugin
A first option would be to use the Maven GlassFish Plugin. This plugin allows to interact with a local or remote GlassFish install and the management of Glassfish domains and component deployments from within the Maven build lifecycle.
Maven Embedded GlassFish Plugin
The second option would be to use the Maven Embedded Glassfish Plugin. As stated by its name, this plugin doesn't rely on an existing install but uses an embedded GlassFish, running in the same JVM as the plugin. This plugin is extremely nice if you want to keep your build portable (anybody can get your POM and run a build involving GlassFish without having it installed) with almost the same features as a normal GlassFish install, except clustering of course (you can use a preconfigured domain.xml if you want). See Testing with the GlassFish Maven plugin and JavaDB Embedded for an example.
Maven Cargo Plugin
The work initiated by Kohsuke Kawagushi as been finally integrated in Cargo and, starting with Cargo 1.0.1, GlassFish 3.x is now supported. Using the Maven Cargo plugin is thus a third option. This would be interesting for builds that want to interact with containers in an agnostic way. But I'm not sure Cargo allows all the flexibility of the GlassFish specific plugin(s) (e.g. deployment of JMS resources, etc).

Categories

Resources