Reference External Project in Spring Configuration - spring

I am trying to reference a project in my main project. I am a .NET developer so I am having a hard time knowing the correct way to reference it. I have a data project and a data project in a MAVEN multiple project setup. In the screenshot you can see I am trying to reference a DAO object from my data project in the security.xml file in my Spring MVC web project. When I run the project it says it can not find the correct class.

Actually I fixed this by adding a Maven dependency of my project, which created a JAR for Tomcat, and fixed the issue. I didn't know you could search the Maven Local Repository to use your own projects.

Related

Difference between a JSF and a Maven project

For my new JAVA application, I want to start creating a new JSF2.2 project with IntelliJ. This project will be a web application and will be using maven.
In IntelliJ Idea, when i click on "create a new project", and then in the left panel select "Maven", it gives me the option of "create from archetype". If I select this check box, it gives me a list of archetypes, with many including jsf in their names.
I am confused what is the difference in creating a maven project without these archetypes and giving it my own groupId, artifactid and so on as compared to creating a project with any of the given jsf archetype?
Like I stated above, the project that i am starting will be a JSF based web application.
EDIT 1
I made the project with maven-archtype-webapp and it created a file index.jsp in the webapp folder. Is this a problem as i normally work with .xhtml files
Maven archetypes are templates. They create a proper project structure for you, depending on whether you want to create a standalone, JSF, ear etc. project.
All these projects are built with Maven, and create a GAV (groupId:artifactId:version) for the created artifacts.

Explain structure of Eclipse-Maven Web project in Spring using Kepler

I am using Kepler to build a Eclipse-Maven project in eclispe. While making the project I am skipping archetype selection on first wizard. then I am selecting packaging as "war".
Eclipse provides me a basic structure after above steps. However, as this is my first Spring/Maven application, I am unable to completely understand the structure.
My Main issue is where to keep my web.xml. No WEB-INF folder is provided, while a META-INF folder is provided.
Also where to keep the basic Dispatcher-Servlet for project and others like root-context, servlet-context etc..
Do I need to create these folders by myself. If yes, Where please? As I am creating a RESTful service, I won't have any views but I guess web.xml is still a must. Currently I am unable to upload an image(nothing happens when I try uploading), will try again soon.
While making the project I am skipping archetype selection on first
wizard. then I am selecting packaging as "war".
You need to select the maven archetype as: maven-archetype-webapp to get the WEB-INF folder & web.xml
Check this out

How can I create web fragment project in Intellij Idea

I'm looking for creating a small web framework on top of the standard servlet-3.x specifications. Main motive is to reduce the boiler plate codes and abstractions. After I read the servlet specifications it looks without using JAX-RS or SparkJava I can create small web framework for API developments.
I'm planning to use the web-fragments method to create my framework level filters, and other beans and package it as jar. So application developer create the war project with web.xml with the metadata-complete option set to false.
I can see the web-fragment project template in eclipse but I want to develop this project using maven. With Intellij I can't see any such options for web fragment projects alone. I want to create simple maven project which ship the jar with web-fragment.xml in it, so other war projects can make use of it.
So is there any plugins or other options available to develop web fragment projects in Intellij ?
Any jar file added to the WEB-INF/lib directory of a web application is technically a "web fragment", whether it has a META-INF/web-fragment.xml file or not.
Therefore, you just need to create a maven project with "jar" packaging and import it into Intellij Idea.
Create a maven project for the fragment. Set the packaging to jar. There is no need to create a war project.
Configure an empty Artifact in the Project Structure dialog:
Using the toolbar buttons, add the WEB-INF/lib folders. Then create an Archive and add the compile output:
Add a Tomcat run configuration, and in the Deployment tab, add the Artifact you just created:
I created an example project that includes all that: https://github.com/ThomasR/web-fragment-idea. Please note that it requires TomEE+.

Netbeans Project Configuration When Using Maven Project

does anyone know how to configure a project using maven? My issue is that when I create a project by doing New->Maven->Enterprise Application Project, I don't get all the IDE helpers that are available when I create the equivalent project using the default (which is an Ant project) option by doing New->Java EE->Enterprise Application Project.
If I go to the generated Main.java in the default project I get the option to use ALT+Insert which brings up useful Java EE code insertion helpers such as "Call Enterprise Bean", "Use Database", etc. These are not available in the maven generated project.
Looking at the default project's files, the project.xml contains this entry "org.netbeans.modules.j2ee.clientproject", which I believe is the IDEs instruction to generate the Java EE helpers for this project.
The maven projects project files, pox.xml and nb-configuration.xml, haven't got this entry. The nb-configuration.xml file does however have these entries:
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>1.7</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv3ee6</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
which must have something to do with the project setup. They don't give Java EE helpers though. Anyone have any idea how to add something like the defaults projects "org.netbeans.modules.j2ee.clientproject" to the maven project to get the helpers working??
Any help appreciated.

How come my spring mvc web app works without pom.xml?

I have removed pom.xml from my eclipse project folder.
And I choose run on server option and everything works fine.
I am new to Spring MVC and have been given this project as an interview round.
Spring version 4.0.6, Tomcat 7, Eclipse Juno
Any help here is appreciated.
pom.xml is the build configuration file for the Maven building tool, Using Maven is optional as you can use any building tool of choice, for example Ant, Maven, Gradle ... etc
The idea behind this build configuration file is that you can define all your dependencies of your project (Spring, Struts, Hibernate, ... etc), source code repository, test cases classes, war file generation info, any other configuration for your project. and If you want to give me your project, you could only give me that pom.xml, and I would simply run maven on this file, and it will download your source code and dependencies, run test cases, build war file and deploy it on application server.
For more information, check the POM reference here
pom.xml is a maven configuration file. You don't need it to run a Spring MVC application.
Having said this, sin maven is what you usually use to build a project, you are not going to be able to build it again if you removed the pom.xml file.
Possible reasons:
You did not reference any Spring MVC class in your Web Appliction
Your Tomcat already has the Spring MVC in its libraries
Spring MVC libraries are copied in your Lib folder of your Web project, so they are carried along within the war (or exploded by the Tomcat plug-in for Eclipse).
As Pablo pointed out, you do not need Maven to add dependencies to your projects.

Resources