In Which folder in my springboot project should i initialize git? - java

I have created a new SpringBoot project with the Spring initializr. I want to add git to the project to track it. In which folder would it be appropriate to initialize git?
I want to do it in the src folder but I fear it might not track all the files needed.

Init git at the root level of your project.
Your fear is justified, since many spring projects have many additional files that should be tracked in addition to your source code and resource files (documentation, pom.xml, etc)

Related

What is the proper java app directory structure with Tomcat?

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.

Eclipse: how to properly integrate a Maven/Ant project into a larger one?

I have a Java project that depends on a 3-rd party component. This component is available both as a jar and as a Maven/Ant project. One option for me is to simply add the jar as a library. However, I prefer to add the source code into my project since I may need to slightly modify their source code to better suit my needs.
What's the right way to do it in Eclipse?
My main project has a simple structure: src/ and lib/. The external component also has a standard structure: src/, test/, build/, target/, pom.xml, build.xml. So do I need to copy piece by piece (like contents of one src/ into the other src/), in which case what goes where? Or do I somehow copy it all at once? Or smth else?
The best way would be if you use maven on your projet for dependency management. This way, if you have the other projects open in eclipse, your project will resolve them as local projects, but if you don't, maven will try to fetch the jars from the configured nexus repository.
This way, you avoid having to manually configure your Eclipse projects. Maven will be able to configure your project anywhere you want to build it, not having to manually configure dependency resolution.
Import both the projects into eclipse. Add the reference of 3pp jar project to your project as a reference by clicking on Add on build path option. While delivering it as output there will be a dependency to the 3pp jar project. So either deliver it as separate jar and add it to classpath while executing your project else you have to copy the entire source files into your project and deliver it test complete jar.
Making a jar will be handled by eclipse itself.

Can files outside of the Maven folder structure get compiled?

We have a Java project that was modified about 2 years ago based on the dates.
The project uses a the Play Framework which as I recalled built and ran just fine back in 2012.
The developer apparently had tried to change the project to be a Maven project but the folder structure is all over the place and not within the Maven src folder structure.
Attempting to run the Play commands does not work on building the project any longer and using the Maven commands does not compile the code.
What occurs is just the packaging of all of the folders and source code into a .jar file.
So the question is 'Can files outside of the Maven folder structure get compiled?' if so how, OR do I need to restructure all the code to be placed into the proper Maven folder structure to try and get this to work again?
Thanks for your time.
Rough view of the folder tree below: Unable to post the POM as it is on another system
Project Name
src
main/java/
trunk
Project Name
... play framework folder structure in here eclipse, modules, precompiled, tmp
conf
lib
Web Content
META-INF
WEB-INF
Yes you can compile files in a non-standard Maven folder structure. Maven natively supports multiple source directories for the purposes of generated sources.
Read the Maven use guide When You Can't Use the Conventions
Using Multiple Source Directories This occurs when you are producing a
single JAR (or other artifact), and have several source directories
with classes you want to include.
This answer shows how to edit the directory structure in Maven by specifying the appropriate properties to override from the superpom.
The Maven pom docs show the build element set mentioned in the link above.
As a side note this answer covers a non standard directory layout for building war.

where to put jar files inside repository

I've got a Java project hosted on github. My project needs few custom .jar files to be imported. Since I was to be able to run the project anywhere, I want to include jar files inside the git repository. Is there a recommended, conventional place where jar files should be kept, e.g. lib dir of the root project directory?
PS
At the moment I'm not using Maven and I'm not considering it.
The usual case is actually a lib folder. Or webapp/WEB-INF/lib it is a web application.
But ths usual case is bad. I would not put jars in my source management system. If you need to add references to another project, you might consider having a look a git submodules (though you are using Github).

Nesting projects with shared resources in Eclipse

I have a custom web application project, where project and webapp are Eclipse projects. Assume a structure like the following
/project
/webapp
/_src
/com.webapp.servlets
/com.webapp.domain
/com.webapp.services
Now I want to create java command line based tool to simulate the operations of a servlet. It's going to require classes from my domain package. I also need to split this command line application from the web application project. I would also need to extract those shared classes into another project as well.
I would like to have this type of structure
/project
/webapp
/_src
/com.webapp.servlets
/com.webapp.services
/commandline
/_src
/com.commandline.simulation
/shared
/_src
/com.webapp.domain
How can I achieve this nested project structure with shared resources in Eclipse (Indigo)?
This was pretty simple. Create a new folder in your root project project. Then Create a Java Project but don't use default location, use the new folder you created. This will create a new entry in your project explorer, but on the file system you will have nested projects.
In projects that require resources from other projects just configure the build path by adding the projects you need,

Categories

Resources