简体   繁体   中英

What is a standard location for Typesafe Config file in a project directory structure?

I'm a newbie to Scala and the JVM.

I've created a project via Typesafe Activator , and I'm adding configuration to it using Typesafe Config .

The documentation for Typesafe Config says that I can put the config file anywhere on the classpath under a number of different names .

Is there a standard location for each of these files?

I am also unfamiliar with determining or modifying the classpath for such a project, but that may be a separate question.

EDIT: Here is the directory structure

/home/d/projects/test/minimal-scala1/
▸ lib/
▸ project/
▾ src/
  ▾ main/
▸ scala/
  ▸ test/
▸ target/
  activator*
  activator-launch-1.2.3.jar
  activator-sbt-echo-akka-shim.sbt
  activator.bat*
  build.sbt
  LICENSE

Short Answer

If you are developing a third party lib to be used by other projects

src/main/resources/reference.conf

If you are developing a regular application

src/main/resources/application.conf

Long Answer

  • system properties
    Not a file obviously. You can specify them on command line when starting the app
    sbt -Dmy.property=value run
  • application.conf
    src/main/resources/application.conf
  • application.json
    src/main/resources/application.json
    Note: .conf format is more commonly used, you can skip this file.
  • application.properties
    src/main/resources/application.properties
    Note: .conf format is more commonly used, you can skip this file.
  • reference.conf
    src/main/resources/reference.conf
    Note: Although it is meant to be provided by third party libs, but nothing prevents you from using the file in regular applications.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM