azure函数maven插件问题:请降级项目编译版本,然后重试



运行后我得到下一个问题:

$ mvn azure-functions:deploy
[ERROR] Failed to execute goal com.microsoft.azure:azure-functions-maven-plugin:1.9.0:deploy (default-cli) on project helidon-examples-microprofile-azure-functions: Your function app artifact compile version is higher than the java version in function host, please downgrade the project compile version and try again. -> [Help 1]

我不知道那个功能主机是什么意思。它建议降级编译版本(目前是jdk 11(,但我不能降级它,因为我的应用程序依赖于Helidon,jdk 11支持这一点。

这些是运行mvn包后生成的文件。库包含依赖项。

$ ls target/azure-functions/function2-helidon-azure/
helidon-examples-microprofile-azure-functions.jar  host.json  lib  local.settings.json  toUpperCase

这是java版本:

$ java -version
openjdk version "11.0.7" 2020-04-14 LTS
OpenJDK Runtime Environment 20.4-(Zulu-11.39+15-linux_x64)-Microsoft-Azure-restricted (build 11.0.7+10-LTS)
OpenJDK 64-Bit Server VM 20.4-(Zulu-11.39+15-linux_x64)-Microsoft-Azure-restricted (build 11.0.7+10-LTS, mixed mode)

以下是JSON文件:

host.json
{
"functionTimeout": "00:09:00",
"version": "3.0"
}
local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"AzureWebJobsDashboard": "",
"FUNCTIONS_WORKER_RUNTIME": "java"
}
}

pom.xml文件是:

<?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>
<parent>
<groupId>io.helidon.applications</groupId>
<artifactId>helidon-mp</artifactId>
<version>2.0.3-SNAPSHOT</version>
<relativePath>../../../applications/mp/pom.xml</relativePath>
</parent>

<properties>
<java.version>11</java.version>
<functionAppName>function2-helidon-azure</functionAppName>
<functionAppRegion>westus</functionAppRegion>
<functionResourceGroup>java-function-group</functionResourceGroup>
<stagingDirectory>${project.build.directory}/azure-functions/${functionAppName}</stagingDirectory>
<azure.functions.maven.plugin.version>1.9.0</azure.functions.maven.plugin.version>
<azure.functions.java.library.version>1.4.0</azure.functions.java.library.version>

</properties>

<artifactId>helidon-examples-microprofile-azure-functions</artifactId>
<name>Helidon Microprofile Examples Azure Functions</name>
<dependencies>
<dependency>
<groupId>com.microsoft.azure.functions</groupId>
<artifactId>azure-functions-java-library</artifactId>
<version>${azure.functions.java.library.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.cloud</groupId>
<artifactId>helidon-microprofile-cloud-azure-functions</artifactId>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>${basedir}</directory>
<includes>
<include>obj/**</include>
</includes>
</fileset>
<fileset>
<directory>${basedir}</directory>
<includes>
<include>extensions.csproj</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-functions-maven-plugin</artifactId>
<version>${azure.functions.maven.plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${stagingDirectory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<includeScope>runtime</includeScope>
<excludeArtifactIds>azure-functions-java-library</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-functions-maven-plugin</artifactId>
<configuration>
<resourceGroup>${functionResourceGroup}</resourceGroup>
<appName>${functionAppName}</appName>
<region>${functionAppRegion}</region>
<appSettings>
<!-- Run Azure Function from package file by default -->
<property>
<name>WEBSITE_RUN_FROM_PACKAGE</name>
<value>1</value>
</property>
<property>
<name>FUNCTIONS_EXTENSION_VERSION</name>
<value>~3</value>
</property>
<property>
<name>FUNCTIONS_WORKER_RUNTIME</name>
<value>java</value>
</property>
</appSettings>
</configuration>
<executions>
<execution>
<id>package-functions</id>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>
${stagingDirectory}
</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/azure
</directory>
<includes>
<include>**</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

我按照这个例子修复了它:https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-first-azure-function-azure-cli?pivots=programming-语言java&tabs=bash%2浏览器

在azure函数maven插件中,我缺少"配置"下的部分:

<runtime>
<os>linux</os>
<javaVersion>11</javaVersion>
</runtime>

之后还有其他问题。

我解决了在"配置"部分添加下一个:

<appServicePlanName>java-functions-app-service-plan</appServicePlanName>

属性"functionResourceGroup"的值也拼写错误。值为:

<functionResourceGroup>java-functions-group</functionResourceGroup>

相关内容

  • 没有找到相关文章

最新更新