1、[ERROR] ‘build.resources.resource.directory‘
解决:需要在pom.xml的project->build->resources节点下,加入以下节点:
(解决时,添加了directory节点)
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>META-INF/*.SF</include>
<include>META-INF/*.DSA</include>
<include>META-INF/*.RSA</include>
<include>META-INF/*.MF</include>
</includes>
<excludes>
<exclude>META-INF/*</exclude>
</excludes>
</resource>
</resources>
14
1
<resources>
2
<resource>
3
<directory>src/main/resources</directory>
4
<includes>
5
<include>META-INF/*.SF</include>
6
<include>META-INF/*.DSA</include>
7
<include>META-INF/*.RSA</include>
8
<include>META-INF/*.MF</include>
9
</includes>
10
<excludes>
11
<exclude>META-INF/*</exclude>
12
</excludes>
13
</resource>
14
</resources>
2、
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project HandleJCYContent: Cannot create resource output directory: F:\workspace_idea\HandleJCYCon
tent\target\classes -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project HandleJCYContent: Cannot create resource
output directory: F:\workspace_idea\HandleJCYContent\target\classes
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
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:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
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.MojoExecutionException: Cannot create resource output directory: F:\workspace_idea\HandleJCYContent\target\classes
at org.apache.maven.plugin.resources.ResourcesMojo.execute(ResourcesMojo.java:307)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: org.apache.maven.shared.filtering.MavenFilteringException: Cannot create resource output directory: F:\workspace_idea\HandleJCYContent\target\classes
at org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.filterResources(DefaultMavenResourcesFiltering.java:215)
at org.apache.maven.plugin.resources.ResourcesMojo.execute(ResourcesMojo.java:301)
... 22 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]
39
1
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project HandleJCYContent: Cannot create resource output directory: F:\workspace_idea\HandleJCYCon
2
tent\target\classes -> [Help 1]
3
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project HandleJCYContent: Cannot create resource
4
output directory: F:\workspace_idea\HandleJCYContent\target\classes
5
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
6
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
7
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
8
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
9
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
10
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
11
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
12
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
13
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
14
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
15
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
16
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
17
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
18
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
20
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
21
at java.lang.reflect.Method.invoke(Method.java:497)
22
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
23
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
24
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
25
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
26
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot create resource output directory: F:\workspace_idea\HandleJCYContent\target\classes
27
at org.apache.maven.plugin.resources.ResourcesMojo.execute(ResourcesMojo.java:307)
28
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
29
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
30
... 20 more
31
Caused by: org.apache.maven.shared.filtering.MavenFilteringException: Cannot create resource output directory: F:\workspace_idea\HandleJCYContent\target\classes
32
at org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.filterResources(DefaultMavenResourcesFiltering.java:215)
33
at org.apache.maven.plugin.resources.ResourcesMojo.execute(ResourcesMojo.java:301)
34
... 22 more
35
[ERROR]
36
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
37
[ERROR]
38
[ERROR] For more information about the errors and possible solutions, please read the following articles:
39
[ERROR] [Help 1]
解决:target文件被占用,关闭其他程序。
3、
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:1.7:shade (default) on project HandleJCYContent: Error creating shaded jar: For artifact {null:null:null:jar}: The groupId cannot be empty
. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:1.7:shade (default) on project HandleJCYContent: Error creating shaded jar: For artifact {
null:null:null:jar}: The groupId cannot be empty.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
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:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
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.MojoExecutionException: Error creating shaded jar: For artifact {null:null:null:jar}: The groupId cannot be empty.
at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:553)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: org.apache.maven.artifact.InvalidArtifactRTException: For artifact {null:null:null:jar}: The groupId cannot be empty.
at org.apache.maven.artifact.DefaultArtifact.validateIdentity(DefaultArtifact.java:130)
at org.apache.maven.artifact.DefaultArtifact.<init>(DefaultArtifact.java:123)
at org.apache.maven.bridge.MavenRepositorySystem.XcreateArtifact(MavenRepositorySystem.java:564)
at org.apache.maven.bridge.MavenRepositorySystem.XcreateArtifact(MavenRepositorySystem.java:524)
at org.apache.maven.bridge.MavenRepositorySystem.XcreateArtifact(MavenRepositorySystem.java:518)
at org.apache.maven.bridge.MavenRepositorySystem.XcreateArtifact(MavenRepositorySystem.java:476)
at org.apache.maven.bridge.MavenRepositorySystem.createArtifact(MavenRepositorySystem.java:79)
at org.apache.maven.project.DefaultProjectBuilder.initProject(DefaultProjectBuilder.java:704)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:176)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:368)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:287)
at org.apache.maven.project.artifact.MavenMetadataSource.retrieveRelocatedProject(MavenMetadataSource.java:577)
at org.apache.maven.project.artifact.MavenMetadataSource.retrieve(MavenMetadataSource.java:190)
at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.recurse(DefaultLegacyArtifactCollector.java:532)
at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.collect(DefaultLegacyArtifactCollector.java:144)
at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.collect(DefaultLegacyArtifactCollector.java:100)
at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.collect(DefaultLegacyArtifactCollector.java:782)
at org.apache.maven.shared.dependency.tree.DefaultDependencyTreeBuilder.buildDependencyTree(DefaultDependencyTreeBuilder.java:102)
at org.apache.maven.plugins.shade.mojo.ShadeMojo.updateExcludesInDeps(ShadeMojo.java:959)
at org.apache.maven.plugins.shade.mojo.ShadeMojo.createDependencyReducedPom(ShadeMojo.java:932)
at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:546)
... 22 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
58
1
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:1.7:shade (default) on project HandleJCYContent: Error creating shaded jar: For artifact {null:null:null:jar}: The groupId cannot be empty
2
. -> [Help 1]
3
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:1.7:shade (default) on project HandleJCYContent: Error creating shaded jar: For artifact {
4
null:null:null:jar}: The groupId cannot be empty.
5
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
6
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
7
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
8
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
9
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
10
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
11
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
12
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
13
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
14
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
15
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
16
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
17
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
18
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
20
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
21
at java.lang.reflect.Method.invoke(Method.java:497)
22
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
23
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
24
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
25
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
26
Caused by: org.apache.maven.plugin.MojoExecutionException: Error creating shaded jar: For artifact {null:null:null:jar}: The groupId cannot be empty.
27
at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:553)
28
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
29
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
30
... 20 more
31
Caused by: org.apache.maven.artifact.InvalidArtifactRTException: For artifact {null:null:null:jar}: The groupId cannot be empty.
32
at org.apache.maven.artifact.DefaultArtifact.validateIdentity(DefaultArtifact.java:130)
33
at org.apache.maven.artifact.DefaultArtifact.<init>(DefaultArtifact.java:123)
34
at org.apache.maven.bridge.MavenRepositorySystem.XcreateArtifact(MavenRepositorySystem.java:564)
35
at org.apache.maven.bridge.MavenRepositorySystem.XcreateArtifact(MavenRepositorySystem.java:524)
36
at org.apache.maven.bridge.MavenRepositorySystem.XcreateArtifact(MavenRepositorySystem.java:518)
37
at org.apache.maven.bridge.MavenRepositorySystem.XcreateArtifact(MavenRepositorySystem.java:476)
38
at org.apache.maven.bridge.MavenRepositorySystem.createArtifact(MavenRepositorySystem.java:79)
39
at org.apache.maven.project.DefaultProjectBuilder.initProject(DefaultProjectBuilder.java:704)
40
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:176)
41
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:368)
42
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:287)
43
at org.apache.maven.project.artifact.MavenMetadataSource.retrieveRelocatedProject(MavenMetadataSource.java:577)
44
at org.apache.maven.project.artifact.MavenMetadataSource.retrieve(MavenMetadataSource.java:190)
45
at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.recurse(DefaultLegacyArtifactCollector.java:532)
46
at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.collect(DefaultLegacyArtifactCollector.java:144)
47
at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.collect(DefaultLegacyArtifactCollector.java:100)
48
at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.collect(DefaultLegacyArtifactCollector.java:782)
49
at org.apache.maven.shared.dependency.tree.DefaultDependencyTreeBuilder.buildDependencyTree(DefaultDependencyTreeBuilder.java:102)
50
at org.apache.maven.plugins.shade.mojo.ShadeMojo.updateExcludesInDeps(ShadeMojo.java:959)
51
at org.apache.maven.plugins.shade.mojo.ShadeMojo.createDependencyReducedPom(ShadeMojo.java:932)
52
at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:546)
53
... 22 more
54
[ERROR]
55
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
56
[ERROR]
57
[ERROR] For more information about the errors and possible solutions, please read the following articles:
58
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
解决:maven-shade-plugin插件有个配置属性:createDependencyReducedPom,默认值为true。
注意这个属性,如果你用这个插件来deploy,或者发布到中央仓库,这个属性会缩减你的pom文件,会把你依赖的<dependency>干掉。
正确的做法是把这个值改成false,如下:
在project->build->plugins->plugin节点,
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.7</version>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<!-- Additional configuration. -->
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<!--<mainClass>com.inspur.main.HandleContent</mainClass>-->
<mainClass>com.inspur.crontab.CrawlerAndIndexJobRun</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
35
1
<plugin>
2
<groupId>org.apache.maven.plugins</groupId>
3
<artifactId>maven-shade-plugin</artifactId>
4
<version>1.7</version>
5
<configuration>
6
<filters>
7
<filter>
8
<artifact>*:*</artifact>
9
<excludes>
10
<exclude>META-INF/*.SF</exclude>
11
<exclude>META-INF/*.DSA</exclude>
12
<exclude>META-INF/*.RSA</exclude>
13
</excludes>
14
</filter>
15
</filters>
16
<!-- Additional configuration. -->
17
</configuration>
18
<executions>
19
<execution>
20
<phase>package</phase>
21
<goals>
22
<goal>shade</goal>
23
</goals>
24
<configuration>
25
<createDependencyReducedPom>false</createDependencyReducedPom>
26
<transformers>
27
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
28
<!--<mainClass>com.inspur.main.HandleContent</mainClass>-->
29
<mainClass>com.inspur.crontab.CrawlerAndIndexJobRun</mainClass>
30
</transformer>
31
</transformers>
32
</configuration>
33
</execution>
34
</executions>
35
</plugin>
4、在IntelliJ IDEA的termin中运行:
F:\workspace_idea\HandleJCYContent>mvn clean package -e
可在F:\workspace_idea\HandleJCYContent\target成功构建jar包,HandleJCYContent-1.0-SNAPSHOT.jar。
5、删除安全认证:
打开jar包,META-INF目录,删除其中DEPENDENCIES、dgminfo、ECLIPSE_.RSA和ECLIPSE_.SF文件。