Windows中生产conf文件的完整路径

时间:2018-03-20 14:30:55

标签: scala playframework playframework-2.5

我正在尝试使用以下命令在生产模式下启动应用程序:

myapp.bat -Dconfig.resource=c:\mydir\prod\prod.conf

我指定了prod.conf的完整路径,但Play找不到它。我也尝试过引号和正斜杠。该文件在那里,这应该如何工作?

1 个答案:

答案 0 :(得分:1)

根据Play Documentation -Dconfig.resource用于类路径中的资源。

尝试使用-Dconfig.file=c:\mydir\prod\prod.conf

这是另一个更复杂的解决方案:

验证播放2.6:

我们使用Linux启动脚本使用的application.ini

示例:

-J-Xmx1024M
-J-Xms512M
-Dconfig.file=/mydir/prod/prod.conf

Windows启动脚本处理的内容有些不同,因此我们创建了一个windows-installer.bat来对其进行更改。

这里是代码:

@ECHO OFF
pushd %~dp0
REM This file is needed if you want to run the service on a Windows machine.
REM the custom variables that must be adjusted for each project.
@REM SET project=PROJECT-NAME (directory name of the project)
SET project=
FOR %%* in (..) do SET project=%%~nx*
SET search=-
SET replace=_
CALL SET project=%%project:%search%=%replace%%%

@REM other variables
@REM SET home=C:\opt\scala-adapters\%project%
pushd ..
SET home=%CD%
pushd %~dp0

SET driveletter=%CD:~0,2%

@REM --------------------set project name---------------------------------------
SET projecttmp=
SET /p projecttmp="Default project name is [%project%], ENTER if correct otherwise insert project name here: "
IF NOT [%projecttmp%] == [] (
  SET project=%projecttmp%
  )
@REM ---------------------------------------------------------------------------


@REM --------------------set project home path----------------------------------
SET hometmp=
SET /p hometmp="Default project home folder is [%home%], ENTER if correct otherwise insert path here: "
IF NOT [%hometmp%] == [] (
  IF EXIST "%hometmp%" (
    SET home="%hometmp%"
   ) ELSE (
   ECHO !!!!! Your path "%hometmp%" does not exist. Exit!
   PAUSE
   EXIT /B
   )
) 
@REM ---------------------------------------------------------------------------


@REM -------------------------Settings SUMMARY----------------------------------
ECHO +++ Your project name is "%project%"
ECHO +++ Your path is "%home%"
@REM ---------------------------------------------------------------------------


@REM -------------------------create config file--------------------------------
SET file=%home%\%project%_config.txt
SET appini=%home%\conf\application.ini

@REM remove the '-J' prefix that is not needed by Windows.
setlocal enableextensions disabledelayedexpansion
set "search=-J"
set "replace="

IF EXIST "%appini%" (
    @REM Copy the application.ini (created by the build process)
    ECHO copy /y  %appini% %file%
    copy /y  %appini% %file%

    for /f "delims=" %%i in ('type "%file%" ^& break ^> "%file%" ') do (
       set "line=%%i"
       setlocal enabledelayedexpansion
       set "line=!line:%search%=%replace%!"
       >>"%file%" echo(!line!
       endlocal
    )
    ECHO ===%file% created
) ELSE (
    ECHO !!!!! there is no file at %appini%. EXIT!
    PAUSE
    EXIT /B
)
@REM ---------------------------------------------------------------------------


PAUSE

如果您在已部署的应用程序的conf目录中同时存在这个,那么这应该有效。抱歉,我没有Windows环境了。

确保更改PROJECT-NAME。