I've two Spring MVC projects in Eclipse, but the web content is in different positions.
In one app it's located under:
/WebContent
In the other app under:
/src/main/webapp
Why that? What's the difference?
Is there any way I can see how each project was created in order to create a new one in the same fashion?
Project directory structure depends on how it was created and the build tool which you are using.
If you create by selecting File -> New ->Dynamic web project in eclipse, then you find the /WebContent directory.
If it is created using Maven, directory strutcure will be /src/main/webapp.
Please go throuh here for more information on Maven project strutcure.
If someone like me messed up with the project and ended up with both folders but wants to keep the maven structure just disable/re-enable the Dynamic Web Module facet and configure the content directory
Finally, delete the WebContent folder.
Related
I started to learn JSP and Tomcat Container, and I know how the directories must be stored, but I'm confused by several things:
If we use only web app, why do we need the rest of the folders here? (highlighted blue). Can I just delete them and load my project with "web" as root?
How can I initialize Gradle/Maven or use any other framework inside Tomcat web application? (e.g Where to put pom.xml file?)
The folder .idea and the file Tomcat-web-app.iml are necessary for your IDE, configuration is stored there. If you delete them the project will fall apart in your IDE. You can delete the src folder as long as you're not using it.
pom.xml should be put on the root level of your project, so right under Tomcat-web-app/. Afterwards you can initialize it as a Maven project by adding framework support for Maven - right click on your project (Tomcat-web-app) and you should see it there. Refer to this guide if you're having issues. It is much more straight forward however to just create a Maven project from scratch and then copy in your web files.
I have the below Web project which is working fine. I wanted to change the structure of the project into a maven project structure.
So, I modified the project to as shown below(I created a new folder called webapp under src/main and I moved the contents of the folder WebContent into webapp and I deleted WebContent folder) Now the application doesn't work although I deploy it in the Tomcat Server. What is wrong in the below project structure . Please help me out
EDIT: I wanted a maven project structure as shown below which is a standard maven project structure
If you are using eclipse (which it looks like you are), you can use the M2Eclipse plugin, which will provide a "convert to maven" utility. Simply right click the project and go to configure -> convert to Maven.
https://www.eclipse.org/m2e/
The structure you are looking for can be defined at the time of project creation in the source directory screen. If you have an existing project you will need to add a new source folder.
To do so,
Add the folders to your project.
Right click on folder > build path > use as source folder.
I have a Maven based desktop App and I have to convert it to a dynamic web app in eclipse or any other IDE ( I am using Eclipse Neon-Java EE).
I have tried with Project Facets (Right click on project name --> Properties --> Project Facets --> dynamic web app) It generates some files but it doesn't seem to be converted to web as in the project folder still appears the letter "M" and not the golobe icon. When I try to run it in Tomcat it doesn't work.
Project Folder
Any suggestion?
Thank you
Look into the project if you have the Maven convert option...
If not, you should check the property of the project, and change them manually, starting from the Deployment Assembly, the target runtime, check all the facets..
Then take a look into the folder of the project, into .classpath and .project and see if they have been refreshed by Eclipse, the pom should package as a war and so on...
The problem here is that you are fighting with Maven and Eclipse togheter, so my main suggestion to do this in lees time, is to create a new Dynamic project and then to copy and paste all the previous Desktop project.. you can do this in a lot of ways...
Or directly from the IDE, or simply by hand than importing again the project...
Let me know if you try one of the above suggestions :)
Moreover obviously after all of this it won't start in tomcat, you have before to configure your web.xml and so on... but at least your structure will follow the Dynamic Web Project structure standards..
I have an existing project that I'm trying to convert correctly into an Eclipse Dynamic Web Project. I've mostly got it working, however there is on issue that I'm not sure how to fix.
The project has something like 2 modules that share the same Java classes, but need to be deployed as separate webapps into the app server (Tomcat 5.5).
So the folder structure is something like
/Webcontent_root
----/app1
..../WEB-INF etc...
----/app2
..../WEB-INF etc...
Is this something that can be controlled within eclipse?
Thanks
I guess, eclipse can't control project with more than one context.
Approach I.
I think you should create three projects: regular java project with classes, one dynamic web project for first webcontent and one for second. Than tune up "Java Build Path" and "Deployment Assembly" settings.
Approach II.
Or you can create two web projects, first with classes and webcontent, second with webcontent and link to first project ("Java Build Path" and "Deployment Assembly" settings).
Create 2 web project and 1 java project for the shared java source. Both web project can use the shared project as a jar file in their web-inf/lib
As #Nantipov says, use the deployment assembly screen to make web projects get the shared java project as a jar in the library filder.
Yes, it can--just not with the UI in WTP (deployment has always been a sore spot and ongoing effort to improve). The .settings/org.eclipse.wst.common.component in your project controls what Eclipse/WTP thinks of as web content root(s) in your project. Odds are you just need to create a new folder in the project and add it as a sibling to the existing element in that file, but with a correct source-path value.
Does anyone have a skeleton build file that I can modify to war up an eclipse dynamic web project.
I need to war it up and make sure that all the libraries/servlets are in the right place.
Creating a deployable WAR file from Eclipse Project
[I'm going to be voted down because it doesn't directly answer your question, but alas...]
I am also using Eclipse WTP for my web projects but I want to keep my own structure (IMO code should be independent from the tools). Fortunately, you can define where the various assets are located by modifying the project's .settings/org.eclipse.wst.common.component file.