我知道关于这个话题还有很多其他的问题,我已经搜索并阅读了所有这些问题,但即便到目前为止还没有帮助.
共享资源的pom看起来像这样
<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>com.myorganization</groupId>
<artifactId>myapp</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>myapp-resources</artifactId>
<name>Resources Bundle</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-remote-resources-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
它基本上说:拿起资源目录中的所有内容,它确实这样做,所有资源最终都在jar文件的根目录中.同时remote-resources.xml也放在jar META-INF/manifest目录下.所以,一切看起来都很好并且符合预期.
现在,另一个,更难,不工作的部分.使用上面指定的共享资源的模块的pom文件的摘录
<plugin>
<artifactId>maven-remote-resources-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>process-remote-resources</id>
<goals>
<goal>process</goal>
</goals>
<configuration>
<resourceBundles>
<resourceBundle>com.myorganization:myapp-resources:1.0-SNAPSHOT</resourceBundle>
</resourceBundles>
<outputdirectory>${project.build.directory}/shared-resources</outputdirectory>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
所以,在这里说,处理来自resourceBundle的资源并将它们放在shared-resources目录中.但是,没有任何反应.当我尝试执行时,mvn remote-resources:process我收到错误消息,指出参数resourceBundles缺失或无效.如果我运行mvn install那里没有错误,但是当我尝试从shared-resources目录中复制(maven资源插件)时,它只是将其作为不存在的资源目录跳过.
另外,我试图为resourceBundle添加错误的名称,这给了我一个不存在的即时错误,所以我确定我已经正确指定了resourceBundle.
任何人都可以开导我吗?怎么了?谢谢.
编辑: 添加引用共享资源的pom部分作为依赖
<dependency>
<groupId>com.myorganization</groupId>
<artifactId>myapp-resources</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
EDIT2: 添加共享资源jar中包含的remote-resources.xml的内容:
<?xml version="1.0" encoding="UTF-8"?>
<remoteResourcesBundle xsi:schemaLocation="http://maven.apache.org/remote-resources/1.1.0 http://maven.apache.org/xsd/remote-resources-1.1.0.xsd"
xmlns="http://maven.apache.org/remote-resources/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<sourceEncoding>UTF-8</sourceEncoding>
</remoteResourcesBundle>
Run Code Online (Sandbox Code Playgroud)
这个是否应该是空的(除了源编码设置)?
编辑3:
我已经看过用于的xsd架构remote-resource.xml,它似乎不应该是空的,但包含要在进程目标中使用的远程资源的列表.这意味着该文件未正确生成.
EDIT4:
附加执行时抛出的错误mvn remote-resources:process:
The parameters 'resourceBundles' for goal org.apache.maven.plugins:maven-remote-resources-plugin:1.5:process are missing or invalid -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-remote-resources-plugin:1.5:process (default-cli) on project lte-troubleshoting-solution: The parameters 'resourceBundles' for goal org.apache.maven.plugins:maven-remote-resources-plugin:1.5:process are missing or invalid
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:220)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginParameterException: The parameters 'resourceBundles' for goal org.apache.maven.plugins:maven-remote-resources-plugin:1.5:process are missing or invalid
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:581)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:534)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:97)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Run Code Online (Sandbox Code Playgroud)
而且有趣的是,似乎outputDirectory根本没有拾取插件配置中的设置,因为在调试日志中我可以看到该outputDirectory设置被设置为默认值.
hto*_*mek 10
我设法最终找到了解决方案.问题实际上是我必须明确指定pom配置中的包含已remote-resources.xml正确生成并稍后在流程目标中获取所列的所有资源remote-resource.xml.
因此,共享资源模块的最终pom应如下所示(如果要包含所有内容):
<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>com.myorganization</groupId>
<artifactId>myapp</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>myapp-resources</artifactId>
<name>Resources Bundle</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-remote-resources-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>**/*.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
附加说明
似乎outputDirectory对于process目标没有影响,资源在插件中指定的默认路径上被解压缩.
| 归档时间: |
|
| 查看次数: |
7044 次 |
| 最近记录: |