What is the difference between a source folder and a (normal) folder

纵饮孤独 提交于 2019-12-30 01:54:04

问题


I'm following this guide: Spring MVC and I realized that I do not know the difference between a source folder (src) and a plain folder.

I'm using eclipse, so maybe the difference is only useful in an IDE?

Also, I've noticed that java classes tend to go in src folders; whilst every other file goes into a plain folder (or the project root folder).

So, What is the significance of the source folder (src)? Why use a source folder over a plain folder?

Thanks!


回答1:


A source folder is marked by Eclipse as containing java sources. Then, when you compile your project Eclipse will look for your source code into all your source folders.

You can make any folder become a source folder adding it to the java build path. Thus, next time you compile your project Eclipse will also look for java classes in that folder.




回答2:


The source folder contains your source code in relation to the project's build path. In the below Spring Boot project com.example.demo is in the classpath, indicated by package icon (and the .classpath file in the project's root, found outside of eclipse in the project's root folder). The path src/main/java/ is where this package is in relation to the root of the project.

You can remove a source folder (eg src/test/java/) from the build path by right-clicking on the folder Build Path > Remove from Build Path. To add it back to back by right-clicking on the folder that will contain your build path (eg src/test/java/) and then choosing Build Path > Use as Source Folder.



来源:https://stackoverflow.com/questions/12736632/what-is-the-difference-between-a-source-folder-and-a-normal-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!