gpt4 book ai didi

java - Azure Spring Boot部署-容器问题

转载 作者:太空宇宙 更新时间:2023-11-04 10:05:28 25 4
gpt4 key购买 nike

我在 azure 上部署 Spring Boot 时遇到问题。我按照以下步骤操作 microsoft docs我能够在本地启动我的网络服务。我还部署了microsoft的示例并使用了我的mysql数据库,该数据库也托管在azure上并且没有任何问题。

我还将应用程序设置 WEBSITES_CONTAINER_START_TIME_LIMIT 设置为最大值。

这是我的 pom.xml

<groupId>groupId</groupId>
<artifactId>billSharingWebservice</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>


<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.0.6.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<version>5.1.1.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.13</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
</dependencies>

<build>

<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.6.RELEASE</version>
</plugin>

<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<deploymentType>jar</deploymentType>

<!-- Web App information -->
<resourceGroup>billSharing</resourceGroup>
<appName>billsharing</appName>
<region>westeurope</region>

<!-- Java Runtime Stack for Web App on Linux-->
<linuxRuntime>jre8</linuxRuntime>
</configuration>
</plugin>
</plugins>
</build>

在 azure 上部署后,我收到以下日志:

2018-10-25 16:09:22.956 INFO  - Starting container for site
2018-10-25 16:09:22.958 INFO - docker run -d -p 43892:8443 --name billsharing_0 -e PORT=8443 -e WEBSITE_SITE_NAME=billsharing -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_INSTANCE_ID=96d743e51352785f93233abee2c7fb3857cba42475b37377d206d1fee114218f -e HTTP_LOGGING_ENABLED=1 appsvc/java:8-jre8_0000000000
2018-10-25 16:10:26.869 ERROR - Container billsharing_0 for site billsharing has exited, failing site start

这并没有什么帮助。

也许有人有想法可以帮助我谢谢。

最佳答案

我使用了您的 pom.xml 并将 WEBSITES_CONTAINER_START_TIME_LIMIT 设置为 1800日志流未显示“XXX 的容器 XXX 已成功初始化”并且站点显示不可用服务。

然后我尝试了微软推荐的pom.xml,效果很好。所以也许你可以尝试我的设置。这是我的 pom.xml:

<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>demo</name>
<description>Demo project for Spring Boot</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>


<!-- servlet dependency. -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>

<!-- tomcat support.-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<deploymentType>jar</deploymentType>

<!-- configure app to run on port 80, required by App Service -->
<appSettings>
<property>
<name>JAVA_OPTS</name>
<value>-Dserver.port=80</value>
</property>
</appSettings>

<!-- Web App information -->
<resourceGroup>myStorageGroup</resourceGroup>
<appName>mvntest03</appName>
<region>eastus</region>

<!-- Java Runtime Stack for Web App on Linux-->
<linuxRuntime>jre8</linuxRuntime>
</configuration>
</plugin>
</plugins>
</build>

这是我的日志流 page .

如果您还有其他设置或仍有疑问,请告诉我。

关于java - Azure Spring Boot部署-容器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52994217/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com