내가 자원에서 파일을 config (설정) akka 배우가 오전 스칼라 SBT에서 자원 폴더 아래에 내가 아래로 자원을로드하고방법,
src/main/resources/remote_app.conf
src/main/scala/actors/Notification.scala
을로드 파일을 얻을 수
1.
val configFile = getClass.getClassLoader.getResource("remote_app.conf").getFile
val config_mediation = ConfigFactory.parseFile(new File(configFile))
actorSystem = ActorSystem("MediationActorSystem", config_mediation)
2.
val path = getClass.getResource("/remote_app.conf").getFile
val config_mediation = ConfigFactory.parseFile(new File(path))
actorSystem = ActorSystem("MediationActorSystem", config_mediation)
모두 주 프로그램에서 실행하고 아래의 로그를 얻을 때 작동합니다.
[정보] [11/21/2016 21 : 05 : 02.835] [주] [원격] 원격 시작; 주소에서 수신 : [akka.tcp : //[email protected] : 7070] [INFO] [11/21/2016 21 : 05 : 02.838] [주] [Remoting] 원격으로 수신 대기중인 주소 : [akka.tcp : //[email protected] : 7070]
I는 SBT 시험하여 병을 생성하고 : 어셈블리 및 SBT 아래와 같은 기본 클래스를 실행 :
resourceDirectory in Compile := baseDirectory.value /"src/main/resources"
resourceDirectory in Test := baseDirectory.value /"src/main/resources"
java -cp <jar> <args>
그 생략 항아리에서 실행할 때 구성 파일을로드 할 수 있습니다. 무엇이든지 잘못하고 있습니다.
답변 해 주셔서 감사합니다. 이 getResourceAsStream은 입력 스트림'getClass.getResourceAsStream ("/ remote_app.conf")'를 제공합니다. 이 ConfigFactory'val config_mediation = ConfigFactory.parseFile (새 파일 (경로))'에는 입력 스트림을 구문 분석 할 수있는 지원이 없습니다. 이 일을 할 수있는 방법이 있나요 .. 구문 분석 문자열 거기 또는 구문 분석기 – Gopi