mar*_*rea 2 java spring azure spring-boot azure-webjobs
是否可以通过 web.config 文件将命令行参数传递给 Azure 上的 Spring boot 应用程序?我们的应用程序已启动并正在运行,但我们需要设置:
--spring.profiles.active=local
Run Code Online (Sandbox Code Playgroud)
在启动时。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="ack=t-Djava.net.preferIPv4Strue -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\myjar-0.0.1.jar"">
</httpPlatform>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我得到了微软的回复,他们有两种方式:
将“environmentVariables”块添加到上面的 xml 中:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\AssetCommander-0.0.1.jar"">
<environmentVariables>
<environmentVariable name="JAVA_OPTS" value="-Dspring.profiles.active=dev" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
[
3、实际上,这些都不适合我们。我们必须这样做:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dspring.profiles.active=%spring.profiles.active% -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\AssetCommander-0.0.1.jar"">
</httpPlatform>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
和上面#2。
| 归档时间: |
|
| 查看次数: |
2221 次 |
| 最近记录: |