r/javahelp • • May 18 '20

What files should be ignored with a Java Spring webservice (aka, what files should be added to .gitignore typically)?

So, I am more familiar with Angular than Java and currently learning Java Spring. I understand with JavaScript Angular, typically .gitignore is set to simply ignore the node_modules folder, as it is large and you don't need it thanks to the package.json file.

However, I am not clear if I need to do something similar for a Java Spring webservice project? I made one via start(dot)spring(dot)io website. Then build stuff up around it. I understand that JARS are installed or imported (again, new to JAVA, so don't know the correct term). I'm guessing those are similar to the node_module files with Javascript?

Either way, is there anything that should be added to a .gitignore file when sending it to github typically? What files or folders are typically ignored in a standard type of Java Spring webservice?

16 Upvotes

11 comments sorted by

9

u/Mungrel000 May 18 '20

gitignore.io

1

u/Cscareermetatime May 19 '20

gitignore.io

That doesn't seem to have stuff for Java Spring Boot though, any suggestions for that?

4

u/Mungrel000 May 19 '20

Java and whatever your build tool is (i.e. Maven, or Gradle, etc), will probably cover most of the files that need to be ignored.

1

u/mwhitey082002 May 18 '20

Are you using Spring or Spring Boot?

3

u/kpolli64 May 19 '20

Everything in the target directory

1

u/guss_bro May 19 '20

Look at this. This is what I use in my projects that have both spring boot and JavaScript stuff.

https://github.com/jhipster/jhipster-sample-app/blob/master/.gitignore

1

u/BorgerBill May 19 '20

Here's mine from my current project:

tags
*.pdf
*.TTF
target/
.*.swp
.*.un~

Those last two are Vim backup and undo files...

1

u/anyusernamesffs May 19 '20

I'm developing with Spring boot and have these in my .gitignore:

bin
build
.classpath
.gradle
.project
.settings
.idea (if you use intellij)

And just use .gitignore when you need to - if you see lots of code being pushed that isn't necessary, ignore it.

1

u/nutrecht Lead Software Engineer / EU / 20+ YXP May 19 '20

There's generally nothing Spring (Boot) specific that needs to be ignored. Just use the standards for maven and gradle projects.