我无法让 Spring Boot API 在 Azure 应用服务上运行。我已遵循 Microsoft 关于 https://learn.microsoft.com/en-us/java/azure/spring-framework/deploy-spring-boot-java-web-app-on-azure 的指南但到目前为止还没有运气。
应用程序确实启动了(我可以在日志文件中看到应用程序启动)但是对应用程序服务 url 的 http 请求总是以超时结束。
我读到 Azure 应用程序服务仅选择在端口 80 或 8080 上运行的嵌入式 tomcat 服务器,但也没有成功。
该应用程序部署在 www 根目录中,并且还部署了适当的 web.config。
我试过使用和不使用应用程序服务器(Tomcat 和 Jetty,不需要,因为服务器嵌入在应用程序中)运行应用服务,但这两种方法都失败了。
我是否遗漏了一些其他配置部分?或者这可能与我在 azure 上使用的计划类型有关吗?也许资源有问题?
有什么指点吗?
谢谢,
伯特
最佳答案
请使用 spring 和 azure 社区提供的以下步骤在 azure 上部署 spring boot 应用程序:
1) 进入你有 pom 文件的应用文件夹并运行
确保以下插件应该在 pom 文件中
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>gs-spring-boot</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- tag::actuator[] -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- end::actuator[] -->
<!-- tag::tests[] -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- end::tests[] -->
</dependencies>
<properties>
<java.version>1.8</java.version>
<maven.build.timestamp.format>yyyyMMddHHmmssSSS</maven.build.timestamp.format>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>0.1.5</version>
<configuration>
<authentication>
<serverId>azure-auth</serverId>
</authentication>
<resourceGroup>maven-plugin</resourceGroup>
<appName>maven-web-app-${maven.build.timestamp}</appName>
<region>westus</region>
<javaVersion>1.8</javaVersion>
<deploymentType>ftp</deploymentType>
<stopAppDuringDeployment>true</stopAppDuringDeployment>
<resources>
<resource>
<directory>${project.basedir}/target</directory>
<targetPath>/</targetPath>
<includes>
<include>*.jar</include>
</includes>
</resource>
<resource>
<directory>${project.basedir}</directory>
<targetPath>/</targetPath>
<includes>
<include>web.config</include>
</includes>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
</project>
Note : Make sure you have created web app on azure with same name as
maven-web-app-${maven.build.timestamp}
现在在根目录下创建名为“web.config”的文件,并将你的 jar 添加到 web.comfig
<?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\azure-rest-example-app-0.1.0.jar"">
</httpPlatform>
</system.webServer>
</configuration>
确保应用在本地运行良好。
如果您有多个帐户与您的 id 相关联,请使用以下命令
登录
az 帐户列表
az account set --subscription XXX-XXX-XXX-XXXXXXXXXXXX
现在您需要创建“Microsoft Azure 中的服务主体”
1) 打开一个终端窗口。
2) 通过键入 az login 使用 Azure CLI 登录您的 Azure 帐户
3) 通过键入 az ad sp create-for-rbac --name "vaquarkhan"--password "yourpassword"创建 Azure 服务主体(vaquarkhan 是用户名,yorpassword 是服务主体的密码)。
az ad sp create-for-rbac --name "app-name" --password "password"
注意:如果出现错误需要更改设置---> here
"azure.graphrbac.models.graph_error.GraphErrorException: Guest users are not allowed to perform this action."
如果成功
Azure 应该打印出类似这样的 JSON 响应:
{
"appId": "XXX-XXXX-XXX-XXX-XXXX",
"displayName": "vaquarkhan",
"name": "http://vaquarkhan",
"password": "yourpassword",
"tenant": "YYY-YYYY-YYY-YYY-YYYY"
}
配置 Maven 以使用您的 Azure 服务主体
1) 在文本编辑器中打开您的 Maven settings.xml 文件(通常位于/etc/maven/settings.xml 或 $HOME/.m2/settings.xml)。
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers>
<server>
<id>azure-auth</id>
<configuration>
<client>ur key</client>
<tenant>ur tenant</tenant>
<key>YOUR PASSWORD</key>
<environment>AZURE</environment>
</configuration>
</server>
</servers>
<proxies/>
<profiles>
<profile>
<id>hwx</id>
<repositories>
<repository>
<id>hwx</id>
<name>hwx</name>
<url>http://nexus-private.hortonworks.com/nexus/content/groups/public/</url>
</repository>
</repositories>
</profile>
</profiles>
<mirrors>
<mirror>
<id>public</id>
<mirrorOf>*</mirrorOf>
<url>http://nexus-private.hortonworks.com/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<activeProfiles/>
</settings>
2) 将本教程上一节中的 Azure 服务主体设置添加到 settings.xml 文件中的集合,如下所示:
<servers>
<server>
<id>azure-auth</id>
<configuration>
<client>aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa</client>
<tenant>tttttttt-tttt-tttt-tttt-tttttttttttt</tenant>
<key>pppppppp</key>
<environment>AZURE</environment>
</configuration>
</server>
</servers>
3) 保存并关闭settings.xml文件。
构建您的应用并将其部署到 Azure
1) 运行以下命令
部署网络应用后,访问 Azure 门户进行管理 它。它将列在应用服务中。
点击应用程序。从那里,面向公众的 URL 您的网络应用程序将列在概述部分
确定您的网络应用程序的 URL 您可以单击此链接以 访问 Spring Boot 应用程序并与之交互。
Azure maven 插件文档
Note : The website name has to be globally unique and its generated using app name , make sure name should be unique.
关于java - 在 Azure 应用服务上部署 Spring Boot jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47700526/
我正在尝试使用ruby和Savon来使用网络服务。测试服务为http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2require'rubygems'require'savon'client=Savon::Client.new"http://www.webservicex.net/stockquote.asmx?WSDL"client.get_quotedo|soap|soap.body={:symbol=>"AAPL"}end返回SOAP异常。检查soap信封,在我看来soap请求没有正确的命名空间。任何人都可以建议我
我想安装一个带有一些身份验证的私有(private)Rubygem服务器。我希望能够使用公共(public)Ubuntu服务器托管内部gem。我读到了http://docs.rubygems.org/read/chapter/18.但是那个没有身份验证-如我所见。然后我读到了https://github.com/cwninja/geminabox.但是当我使用基本身份验证(他们在他们的Wiki中有)时,它会提示从我的服务器获取源。所以。如何制作带有身份验证的私有(private)Rubygem服务器?这是不可能的吗?谢谢。编辑:Geminabox问题。我尝试“捆绑”以安装新的gem..
对于具有离线功能的智能手机应用程序,我正在为Xml文件创建单向文本同步。我希望我的服务器将增量/差异(例如GNU差异补丁)发送到目标设备。这是计划:Time=0Server:hasversion_1ofXmlfile(~800kiB)Client:hasversion_1ofXmlfile(~800kiB)Time=1Server:hasversion_1andversion_2ofXmlfile(each~800kiB)computesdeltaoftheseversions(=patch)(~10kiB)sendspatchtoClient(~10kiBtransferred)Cl
我构建了两个需要相互通信和发送文件的Rails应用程序。例如,一个Rails应用程序会发送请求以查看其他应用程序数据库中的表。然后另一个应用程序将呈现该表的json并将其发回。我还希望一个应用程序将存储在其公共(public)目录中的文本文件发送到另一个应用程序的公共(public)目录。我从来没有做过这样的事情,所以我什至不知道从哪里开始。任何帮助,将不胜感激。谢谢! 最佳答案 无论Rails是什么,几乎所有Web应用程序都有您的要求,大多数现代Web应用程序都需要相互通信。但是有一个小小的理解需要你坚持下去,网站不应直接访问彼此
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r
刚入门rails,开始慢慢理解。有人可以解释或给我一些关于在application_controller中编码的好处或时间和原因的想法吗?有哪些用例。您如何为Rails应用程序使用应用程序Controller?我不想在那里放太多代码,因为据我了解,每个请求都会调用此Controller。这是真的? 最佳答案 ApplicationController实际上是您应用程序中的每个其他Controller都将从中继承的类(尽管这不是强制性的)。我同意不要用太多代码弄乱它并保持干净整洁的态度,尽管在某些情况下ApplicationContr
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
最近,当我启动我的Rails服务器时,我收到了一长串警告。虽然它不影响我的应用程序,但我想知道如何解决这些警告。我的估计是imagemagick以某种方式被调用了两次?当我在警告前后检查我的git日志时。我想知道如何解决这个问题。-bcrypt-ruby(3.1.2)-better_errors(1.0.1)+bcrypt(3.1.7)+bcrypt-ruby(3.1.5)-bcrypt(>=3.1.3)+better_errors(1.1.0)bcrypt和imagemagick有关系吗?/Users/rbchris/.rbenv/versions/2.0.0-p247/lib/ru
在Rails4.0.2中,我使用s3_direct_upload和aws-sdkgems直接为s3存储桶上传文件。在开发环境中它工作正常,但在生产环境中它会抛出如下错误,ActionView::Template::Error(noimplicitconversionofnilintoString)在View中,create_cv_url,:id=>"s3_uploader",:key=>"cv_uploads/{unique_id}/${filename}",:key_starts_with=>"cv_uploads/",:callback_param=>"cv[direct_uplo
我是一个Rails初学者,但我想从我的RailsView(html.haml文件)中查看Ruby变量的内容。我试图在ruby中打印出变量(认为它会在终端中出现),但没有得到任何结果。有什么建议吗?我知道Rails调试器,但更喜欢使用inspect来打印我的变量。 最佳答案 您可以在View中使用puts方法将信息输出到服务器控制台。您应该能够在View中的任何位置使用Haml执行以下操作:-puts@my_variable.inspect 关于ruby-on-rails-如何在我的R