Adding resources in IntelliJ for Maven project

后端 未结 7 1309
走了就别回头了
走了就别回头了 2020-11-28 07:36

I have a project structure like this:

src
 |-main
    |-java
       |-com.abc.xyz
          |-Login.java

I have to add a resource file to t

7条回答
  •  忘掉有多难
    2020-11-28 08:13

    The launcher.properties should not be under a folder called Login. It should be placed directly in the src/main/resources/com/abc/xyz folder.


    It is really as simple as I said but if the resources folder is not marked as a sources folder then this may be the problem.

    This is the initial class and setup:

    enter image description here

    Now create the resources folder:

    enter image description here

    enter image description here

    This newly created folder should be automatically marked as a sources folder and if it is blue color marked then it is. Otherwise you'll have to mark it manually:

    enter image description here

    Now you'll be able to add packages to it:

    enter image description here

    enter image description here

    And now you can add the file to it:

    enter image description here

    enter image description here

    And rerunning the application will not give you any null value back:

    enter image description here

    And the package view will surely show the launchers.properties file as well:

    enter image description here

提交回复
热议问题