如果混合全局构建和配置文件构建,cxf-codegen-plugin 会生成错误代码
cxf-codegen-plugin generates bad code if mixing global build and profile build
Java SOAP 网络应用程序。我有多项服务要查询,我必须根据环境(测试、生产)区分其中一项。我认为将通用 WSDL 放在一起并为需要区分的服务创建两个配置文件是合乎逻辑的。不幸的是,我无法在运行时以编程方式更改 WSDL_LOCATION 。所以我写了(将 XML 简化为 YAML 并删除明显的元素,如 <phase>generate-sources</phase>
):
project:
build:
plugins:
plugin:
executions:
execution:
id: "generate-common-sources"
configuration:
wsdlOptions:
wsdlOption:
-
wsdl: "${project.basedir}/src/main/resources/wsdl/Service1.wsdl"
wsdlLocation: "/wsdl/Service1.wsdl"
-
wsdl: "${project.basedir}/src/main/resources/wsdl/Service2.wsdl"
wsdlLocation: "/wsdl/Service2.wsdl"
profiles:
profile:
id: "env-test"
build:
plugins:
plugin:
executions:
execution:
id: "generate-test-sources"
configuration:
wsdlOptions:
wsdlOption:
wsdl: "${project.basedir}/src/main/resources/wsdl/Service3-test.wsdl"
wsdlLocation: "/wsdl/Service3-test.wsdl"
profile:
id: "env-prod"
build:
# Duplicate env-test here
但这不起作用:Service1 和 Service2 使用完整路径生成 WSDL_LOCATION,这显然在服务器上失败。为什么?
我经过许多诅咒后发现的工作配置是:
project:
build:
plugins:
plugin:
executions:
execution:
id: "generate-common-sources"
configuration:
wsdlOptions: # Keep this empty!
profiles:
profile:
id: "env-test"
build:
plugins:
plugin:
executions:
execution:
id: "generate-test-sources"
configuration:
wsdlOptions:
wsdlOption:
-
wsdl: "${project.basedir}/src/main/resources/wsdl/Service1.wsdl"
wsdlLocation: "/wsdl/Service1.wsdl"
-
wsdl: "${project.basedir}/src/main/resources/wsdl/Service2.wsdl"
wsdlLocation: "/wsdl/Service2.wsdl"
-
wsdl: "${project.basedir}/src/main/resources/wsdl/Service3-test.wsdl"
wsdlLocation: "/wsdl/Service3-test.wsdl"
profile:
id: "env-prod"
build:
# Duplicate env-test here
仍然不清楚为什么我的第一种方法不起作用。
Java SOAP 网络应用程序。我有多项服务要查询,我必须根据环境(测试、生产)区分其中一项。我认为将通用 WSDL 放在一起并为需要区分的服务创建两个配置文件是合乎逻辑的。不幸的是,我无法在运行时以编程方式更改 WSDL_LOCATION 。所以我写了(将 XML 简化为 YAML 并删除明显的元素,如 <phase>generate-sources</phase>
):
project:
build:
plugins:
plugin:
executions:
execution:
id: "generate-common-sources"
configuration:
wsdlOptions:
wsdlOption:
-
wsdl: "${project.basedir}/src/main/resources/wsdl/Service1.wsdl"
wsdlLocation: "/wsdl/Service1.wsdl"
-
wsdl: "${project.basedir}/src/main/resources/wsdl/Service2.wsdl"
wsdlLocation: "/wsdl/Service2.wsdl"
profiles:
profile:
id: "env-test"
build:
plugins:
plugin:
executions:
execution:
id: "generate-test-sources"
configuration:
wsdlOptions:
wsdlOption:
wsdl: "${project.basedir}/src/main/resources/wsdl/Service3-test.wsdl"
wsdlLocation: "/wsdl/Service3-test.wsdl"
profile:
id: "env-prod"
build:
# Duplicate env-test here
但这不起作用:Service1 和 Service2 使用完整路径生成 WSDL_LOCATION,这显然在服务器上失败。为什么?
我经过许多诅咒后发现的工作配置是:
project:
build:
plugins:
plugin:
executions:
execution:
id: "generate-common-sources"
configuration:
wsdlOptions: # Keep this empty!
profiles:
profile:
id: "env-test"
build:
plugins:
plugin:
executions:
execution:
id: "generate-test-sources"
configuration:
wsdlOptions:
wsdlOption:
-
wsdl: "${project.basedir}/src/main/resources/wsdl/Service1.wsdl"
wsdlLocation: "/wsdl/Service1.wsdl"
-
wsdl: "${project.basedir}/src/main/resources/wsdl/Service2.wsdl"
wsdlLocation: "/wsdl/Service2.wsdl"
-
wsdl: "${project.basedir}/src/main/resources/wsdl/Service3-test.wsdl"
wsdlLocation: "/wsdl/Service3-test.wsdl"
profile:
id: "env-prod"
build:
# Duplicate env-test here
仍然不清楚为什么我的第一种方法不起作用。