是否可以通过web.config文件将命令行参数传递给Azure上的Spring启动应用程序?我们的应用程序已启动并正在运行,但我们需要设置:
--spring.profiles.active=local
启动时。
<?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>
答案 0 :(得分:2)
我收到了微软的回复,他们有两种方式:
将“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>
[
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>
和#2以上。
答案 1 :(得分:0)