IntelliJ IDEA打可运行jar包时的错误

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文件。

原文地址:https://www.cnblogs.com/myitroad/p/8436197.html

时间: 2024-10-14 10:22:03

IntelliJ IDEA打可运行jar包时的错误的相关文章

运行jar包时读取jar里面的文件

在开发过程中,我们经常会遇到读取配置文件的情况,对于配置文件的读取,根据环境等情况又各有不同,一般情况下,如果从非jar包中使用相对/路径,比较简单,就不在累述了,而在很多 情况下,我们需要把我们的class打包成jar文件,进行使用,这时就会发现,我们先前如果没有考虑到这些,可能就行不通了,那么,该如何解决呢?方法如下 : 有如下路径 : Web-info--|-->classes--->jdbc.properties |-->lib 此时加 入我们需要读取jdbc.propertie

运行jar包时出现异常:Exception in thread &quot;main&quot; java.lang.ExceptionInInitializerError

/usr/local/java/jdk1.8.0_60/bin/java SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/local/jstorm-2.2.1/wait_deploy/test-jstorm-bolt.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar

Hadoop 运行jar包时 java.lang.ClassNotFoundException: Class com.zhen.mr.RunJob$HotMapper not found

错误如下 Error: java.lang.RuntimeException: java.lang.ClassNotFoundException: Class com.zhen.mr.RunJob$HotMapper not found at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2154) at org.apache.hadoop.mapreduce.task.JobContextImpl.getMap

自建运行jar包引用外用jar包

大家都知道一个java应用项目可以打包成一个jar,当然你必须指定一个拥有main函数的main class作为你这个jar包的程序入口. 具体的方法是修改jar包内目录META-INF下的MANIFEST.MF文件. 比如有个叫做test.jar的jar包,里面有一个拥有main函数的main class:test.someClassName 我们就只要在MANIFEST.MF里面添加如下一句话: Main-Class: test.someClassName 然后我们可以在控制台里输入java

spark提交jar包时出现unsupported major.minor version 52.0错误的解决方案

一.问题: 最近在spark集群上做一个项目,打包提交jar包时,出现了unsupported major.minor version 52.0的报错,而在local模式运行却能正常运行! 二.错误原因: 查阅诸多资料得出的结论就是:项目编译得到的class文件的版本高于运行环境中jre的版本号,高版本JDK编译的class不能在低版本的jvm虚拟机下运行,否则就会报这类错,因此无法运行!49,50,51,52是Java编译器内部的版本号,版本对应信息如下: Unsupported major.

IntelliJ IDEA 问题总结之一 —— jar包、assets、maven、git

由于工作需要,这几天开始弃用eclipse,换idea.用了几天,idea确实有些地方比较方便,但是麻烦也是不少.而且网上对应的资料并没有eclipse那么多,很多都是自己琢磨解决的,所以想弄个帖子来总结一下遇到的问题,做个记录. 1.jar包.导入一个工程,libs下jar包都有,但是代码里就是找不到.这个还算简单,选中jar包右键,有个"add as library ..",就可以了.也可以在项目设置(项目右键菜单open module setting)中libraries中添加.

java工程导成jar包,用批处理运行jar包

新建一个java工程(在本例中的工程名叫JavaProject),在main()里面写入自己要执行的方法. 接下来把工程导成jar包,操作步骤如下: 右键工程名,选择Export,选择java里面的Runnable JAR file(如下图) 点击Next后,在弹出框中选择自己的工程名(类名-工程名),选择jar包上传的位置(如下图:) 点击Finish按钮就可以生成了,双击生成的jar包就可以运行了. 接下来怎么用.bat文件运行jar包呢: 新建一个run.bat文件(文件名随便命名),用记

Intellij Idea系列之导Jar包与编写单元测试(二)

 Intellij Idea系列之导Jar包与编写单元测试(二) 一.初衷 对于很多的初学者来说,Intellij如何导入jar包感到很迷惑,甚至在网上搜过相关文章之后还是云里雾里,本博客通过图文并茂的方式为读者进行清晰的描述,如有疑问请留言.可能很多的大牛会说,你为嘛不用maven或者gradle来弄,多么简单呀,笔者在此声明,本文只是针对初学Intellij的程序员来讲.笔者有意将本博客做成系列文章,后期会有关于如何用Intellij来搭建maven和gradle项目. 二. 导入jar包并

java项目导出为可运行jar包

1.选中要导出的项目, 右键->export,选中java下的JAR file->next,选择要导出的路径->next,finish. 2.选中导出的jar文件用压缩文件管理器打开 3.有个META-INF目录,把里面的MANIFEST.MF文件拖出来.此时MANIFEST文件内容应该只有下面这一行: <span style="font-size:24px;"> Manifest-Version:1.0</span> 4.修改MANIFEST