Windows 中生产配置文件的完整路径

Full path of production conf file in Windows

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

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

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

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

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

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

已验证 Play 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。