英文:
Can't run Core Java web application into Azure Web app
问题
以下是翻译好的内容:
我已经使用maven-archetype-webapp编写了一个核心Java Web应用程序,尝试将jar文件和web.config部署在基于Azure Windows的Web应用程序中,但无法访问URL。我的应用程序中只有主页。并且按照以下步骤操作。我能够在本地系统中运行它并且可以看到主页。
- 在POM中添加了azure-webapp-maven-plugin,并使用mvn azure-webapp:config进行构建,然后在configuration标签内添加了以下标签。
<appSettings>
<property>
<name>JAVA_OPTS</name>
<value>-Dserver.port=80</value>
</property>
</appSettings>
- 使用Java 8和Tomcat 8.5在Windows上创建了Web应用程序。
- 将jar文件和web.config文件部署到wwwroot目录中。
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"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\TestWebApp.jar"">
</httpPlatform>
</system.webServer>
</configuration>
文件夹结构
(图片已省略)
Azure目录结构
(图片已省略)
本地系统输出
(图片已省略)
英文:
I have written a core java web application using maven-archetype-webapp and trying to deploy the jar file and web.config in a azure windows based webapp but not able to access the url. I only have home page inside my application. and following below steps. I am able to run it in my local system and can see the homepage.
- azure-webapp-maven-plugin added in POM and build with mvn azure-webapp:config, then inside configuration tag I added below tag.
<appSettings>
<property>
<name>JAVA_OPTS</name>
<value>-Dserver.port=80</value>
</property>
</appSettings>
- Created a web app in Windowsusing Java 8 and Tomcat 8.5
- Deployed jar file and web.config file inside wwwroot directory
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"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar &quot;%HOME%\site\wwwroot\TestWebApp.jar&quot;">
</httpPlatform>
</system.webServer>
</configuration>
Folder Structure
Azure directory structure
Local system Output:
答案1
得分: 0
感谢@soumen提供的解决方案。
> 将war
文件部署在Azure的webapp
中的wwwroot
文件夹中。
> 在部署之前删除了webapps
中的Root
文件夹,在我的部署之后,新的根文件夹被自动生成,现在我可以访问该URL。
我将其视为一个答案,希望能帮助其他成员。
英文:
Thanks @soumen for the solution.
> Deployed the war
file inside wwwroot
-> webapps
folder in azure
> webapp. Before deploying deleted the Root
folder inside webapps
, after
> my deployment new root folder was automatically generated, now I can
> access the url.
I take it as an answer, hoping to help other members.
专注分享java语言的经验与见解,让所有开发者获益!
评论