How to add resource files in intellij from src/main/java directory(intellij 2016)

549 Views Asked by At

I am trying to get this very small project working in intellij(it already works in eclipse). https://github.com/deanhiller/webpiecesExample which is generated from the webpieces webserver project. When booting the server, it can't find the html files in src/main/java(ie. the html files are there rather than src/main/resources to keep locality with their controllers).

I tried adding java:.html and java:.tag as I thought that would work according to this document

https://www.jetbrains.com/help/idea/2016.2/compiler.html

but that doesn't seem to work. I then also found cmd-; opens a window with resources and you can click on directories to mark them as resource directories. I tried doing that but it won't let me do that on a source directory.

Both gradle and eclipse are all working with this project, but I can't seem to get intellij working. It would be very nice to be able to use intellij on this project.

EDIT: Why put some resources in src/main/java instead of src/main/resources...

It can be very annoying to have to create the same package heirarchy in two directories(and slower as you are doing double the work). Also, you miss the view of controller's relationships to html files. Lastly, some files are referenced like ../example/index.html from the controller and literally it makes more sense to the user then if they are in the same tree. If you did ../../../../src/main/resource/com/buffalo/example/index.html, it actually would not even work as it is a relative classpath reference. After working in both environments, we found the one to be more efficient so even though it flies in the face of best practices, it makes developers faster(so best practices vs. developer speed.....I choose speed personally). BUT NOTE: This is not true on all projects. Most project should stick to src/main/java and src/main/resources.

thanks, Dean

0

There are 0 best solutions below