【Azure 应用服务】在Azure App Service for Windows 中部署Java web项目时候,需要在wwwroot下设置web.config
时间:2020-12-28 11:53:10
收藏:0
阅读:0
问题描述
在Azure App Service for Windows 中部署Java web项目时候,需要在wwwroot下设置web.config,而争对Jar包,war包则有不同的设置方式,一下两段web.config的内容分别对应Jar 和War包
方式一: 启动Jar包的Web.config
<?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" stdoutLogEnabled ="true" stdoutLogFile="%home%\LogFiles\stdout" arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\my-web-project.jar" " >
</httpPlatform> </system.webServer> </configuration>
- stdoutLogEnabled: 为true则会在stdoutLogFile文件夹中记录java启动的日志
- arguments: 配置jar包的启动参数,如端口号,jar包路径,也可以配置utf-8编码方式,避免乱码问题。
方式二: 启动War包的Web.config
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <handlers> <add name="httppPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" /> </handlers> <httpPlatform processPath="%AZURE_TOMCAT8_HOME%\bin\startup.bat"> </httpPlatform> </system.webServer> </configuration>
参考资料
Java sample for Azure App Service: https://github.com/Azure-Samples/app-service-web-java-get-started
评论(0)