我有一个关于POM的项目:
<?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>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
然后我使用mvn clean install
进行编译和安装。我可以在我的.m2
目录中看到artefact:
lukasz@lukasz-XPS-L701X:~$ ls .m2/repository/com/example/demo/
0.0.1-SNAPSHOT maven-metadata-local.xml
直接调用javac
时,我可以在其他项目中使用此文件:
javac -cp .m2/repository/com/example/demo/0.0.1-SNAPSHOT/demo-0.0.1-SNAPSHOT.jar
但是,当我有另一个以demo
为依赖关系的Maven项目时,Maven说它无法找到它。
demo2
POM:
<?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>
<groupId>com.example</groupId>
<artifactId>demo2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo2</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
当我在mvn clean compile
中运行demo2
时,我得到:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building demo2 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ demo2 ---
[INFO] Deleting /home/lukasz/parent/demo2/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ demo2 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ demo2 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/lukasz/parent/demo2/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/lukasz/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,17] cannot find symbol
symbol: class Aclass
location: class com.example.Demo2Application
[ERROR] /home/lukasz/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,32] cannot find symbol
symbol: class Aclass
location: class com.example.Demo2Application
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.053 s
[INFO] Finished at: 2017-02-19T10:45:57+01:00
[INFO] Final Memory: 22M/254M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project demo2: Compilation failure: Compilation failure:
[ERROR] /home/lukasz/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,17] cannot find symbol
[ERROR] symbol: class Aclass
[ERROR] location: class com.example.Demo2Application
[ERROR] /home/lukasz/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,32] cannot find symbol
[ERROR] symbol: class Aclass
[ERROR] location: class com.example.Demo2Application
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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/MojoFailureException
修改
这是ls -lR .m2/repository/com/example/demo/
.m2/repository/com/example/demo/:
total 8
drwxr-xr-x 5 lukasz lukasz 4096 Feb 19 07:12 0.0.1-SNAPSHOT
-rw-r--r-- 1 lukasz lukasz 275 Feb 19 07:07 maven-metadata-local.xml
.m2/repository/com/example/demo/0.0.1-SNAPSHOT:
total 6468
drwxr-xr-x 4 lukasz lukasz 4096 Feb 19 07:07 BOOT-INF
-rw-r--r-- 1 lukasz lukasz 6595868 Feb 19 07:07 demo-0.0.1-SNAPSHOT.jar
-rw-r--r-- 1 lukasz lukasz 1410 Feb 19 01:01 demo-0.0.1-SNAPSHOT.pom
-rw-r--r-- 1 lukasz lukasz 701 Feb 19 07:07 maven-metadata-local.xml
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 META-INF
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 org
-rw-r--r-- 1 lukasz lukasz 185 Feb 19 07:07 _remote.repositories
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/BOOT-INF:
total 8
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 classes
drwxr-xr-x 2 lukasz lukasz 4096 Feb 19 07:07 lib
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/BOOT-INF/classes:
total 4
-rw-r--r-- 1 lukasz lukasz 0 Feb 19 07:07 application.properties
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 com
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/BOOT-INF/classes/com:
total 4
drwxr-xr-x 2 lukasz lukasz 4096 Feb 19 07:07 example
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/BOOT-INF/classes/com/example:
total 8
-rw-r--r-- 1 lukasz lukasz 267 Feb 19 07:07 Aclass.class
-rw-r--r-- 1 lukasz lukasz 694 Feb 19 07:07 DemoApplication.class
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/BOOT-INF/lib:
total 6384
-rw-r--r-- 1 lukasz lukasz 16521 Dec 13 18:09 jcl-over-slf4j-1.7.22.jar
-rw-r--r-- 1 lukasz lukasz 4596 Dec 13 18:09 jul-to-slf4j-1.7.22.jar
-rw-r--r-- 1 lukasz lukasz 23647 Dec 13 18:09 log4j-over-slf4j-1.7.22.jar
-rw-r--r-- 1 lukasz lukasz 305150 Jan 20 19:58 logback-classic-1.1.9.jar
-rw-r--r-- 1 lukasz lukasz 472639 Jan 20 19:57 logback-core-1.1.9.jar
-rw-r--r-- 1 lukasz lukasz 41077 Dec 13 18:07 slf4j-api-1.7.22.jar
-rw-r--r-- 1 lukasz lukasz 273599 Feb 19 2016 snakeyaml-1.17.jar
-rw-r--r-- 1 lukasz lukasz 379905 Jan 25 13:13 spring-aop-4.3.6.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 762701 Jan 25 13:13 spring-beans-4.3.6.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 662119 Jan 30 19:31 spring-boot-1.5.1.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 1038200 Jan 30 19:39 spring-boot-autoconfigure-1.5.1.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 2290 Jan 30 19:45 spring-boot-starter-1.5.1.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 2309 Jan 30 19:45 spring-boot-starter-logging-1.5.1.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 1136805 Jan 25 13:14 spring-context-4.3.6.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 1117842 Jan 25 13:13 spring-core-4.3.6.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 263304 Jan 25 13:14 spring-expression-4.3.6.RELEASE.jar
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/META-INF:
total 8
-rw-r--r-- 1 lukasz lukasz 558 Feb 19 07:07 MANIFEST.MF
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 maven
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/META-INF/maven:
total 4
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 com.example
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/META-INF/maven/com.example:
total 4
drwxr-xr-x 2 lukasz lukasz 4096 Feb 19 07:07 demo
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/META-INF/maven/com.example/demo:
total 8
-rw-r--r-- 1 lukasz lukasz 116 Feb 19 07:07 pom.properties
-rw-r--r-- 1 lukasz lukasz 1410 Feb 19 01:01 pom.xml
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org:
total 4
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 springframework
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org/springframework:
total 4
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 boot
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org/springframework/boot:
total 4
drwxr-xr-x 6 lukasz lukasz 4096 Feb 19 07:07 loader
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org/springframework/boot/loader:
total 92
drwxr-xr-x 2 lukasz lukasz 4096 Feb 19 07:07 archive
drwxr-xr-x 2 lukasz lukasz 4096 Feb 19 07:07 data
-rw-r--r-- 1 lukasz lukasz 1165 Jan 30 19:26 ExecutableArchiveLauncher$1.class
-rw-r--r-- 1 lukasz lukasz 3128 Jan 30 19:26 ExecutableArchiveLauncher.class
drwxr-xr-x 2 lukasz lukasz 4096 Feb 19 07:07 jar
-rw-r--r-- 1 lukasz lukasz 1533 Jan 30 19:26 JarLauncher.class
-rw-r--r-- 1 lukasz lukasz 2415 Jan 30 19:26 LaunchedURLClassLoader$1.class
-rw-r--r-- 1 lukasz lukasz 4698 Jan 30 19:26 LaunchedURLClassLoader.class
-rw-r--r-- 1 lukasz lukasz 4599 Jan 30 19:26 Launcher.class
-rw-r--r-- 1 lukasz lukasz 1468 Jan 30 19:26 MainMethodRunner.class
-rw-r--r-- 1 lukasz lukasz 1382 Jan 30 19:26 PropertiesLauncher$1.class
-rw-r--r-- 1 lukasz lukasz 1454 Jan 30 19:26 PropertiesLauncher$ArchiveEntryFilter.class
-rw-r--r-- 1 lukasz lukasz 16109 Jan 30 19:26 PropertiesLauncher.class
-rw-r--r-- 1 lukasz lukasz 1704 Jan 30 19:26 PropertiesLauncher$FilteredArchive$1.class
-rw-r--r-- 1 lukasz lukasz 2382 Jan 30 19:26 PropertiesLauncher$FilteredArchive.class
-rw-r--r-- 1 lukasz lukasz 1807 Jan 30 19:26 PropertiesLauncher$PrefixMatchingArchiveFilter.class
drwxr-xr-x 2 lukasz lukasz 4096 Feb 19 07:07 util
-rw-r--r-- 1 lukasz lukasz 1669 Jan 30 19:26 WarLauncher.class
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org/springframework/boot/loader/archive:
total 52
-rw-r--r-- 1 lukasz lukasz 906 Jan 30 19:26 Archive.class
-rw-r--r-- 1 lukasz lukasz 302 Jan 30 19:26 Archive$Entry.class
-rw-r--r-- 1 lukasz lukasz 399 Jan 30 19:26 Archive$EntryFilter.class
-rw-r--r-- 1 lukasz lukasz 273 Jan 30 19:26 ExplodedArchive$1.class
-rw-r--r-- 1 lukasz lukasz 4974 Jan 30 19:26 ExplodedArchive.class
-rw-r--r-- 1 lukasz lukasz 1068 Jan 30 19:26 ExplodedArchive$FileEntry.class
-rw-r--r-- 1 lukasz lukasz 3792 Jan 30 19:26 ExplodedArchive$FileEntryIterator.class
-rw-r--r-- 1 lukasz lukasz 1438 Jan 30 19:26 ExplodedArchive$FileEntryIterator$EntryComparator.class
-rw-r--r-- 1 lukasz lukasz 7016 Jan 30 19:26 JarFileArchive.class
-rw-r--r-- 1 lukasz lukasz 1749 Jan 30 19:26 JarFileArchive$EntryIterator.class
-rw-r--r-- 1 lukasz lukasz 1051 Jan 30 19:26 JarFileArchive$JarFileEntry.class
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org/springframework/boot/loader/data:
total 24
-rw-r--r-- 1 lukasz lukasz 1531 Jan 30 19:26 ByteArrayRandomAccessData.class
-rw-r--r-- 1 lukasz lukasz 551 Jan 30 19:26 RandomAccessData.class
-rw-r--r-- 1 lukasz lukasz 3390 Jan 30 19:26 RandomAccessDataFile.class
-rw-r--r-- 1 lukasz lukasz 3534 Jan 30 19:26 RandomAccessDataFile$DataInputStream.class
-rw-r--r-- 1 lukasz lukasz 2051 Jan 30 19:26 RandomAccessDataFile$FilePool.class
-rw-r--r-- 1 lukasz lukasz 1341 Jan 30 19:26 RandomAccessData$ResourceAccess.class
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org/springframework/boot/loader/jar:
total 136
-rw-r--r-- 1 lukasz lukasz 4457 Jan 30 19:26 AsciiBytes.class
-rw-r--r-- 1 lukasz lukasz 2169 Jan 30 19:26 Bytes.class
-rw-r--r-- 1 lukasz lukasz 2943 Jan 30 19:26 CentralDirectoryEndRecord.class
-rw-r--r-- 1 lukasz lukasz 5449 Jan 30 19:26 CentralDirectoryFileHeader.class
-rw-r--r-- 1 lukasz lukasz 4602 Jan 30 19:26 CentralDirectoryParser.class
-rw-r--r-- 1 lukasz lukasz 430 Jan 30 19:26 CentralDirectoryVisitor.class
-rw-r--r-- 1 lukasz lukasz 306 Jan 30 19:26 FileHeader.class
-rw-r--r-- 1 lukasz lukasz 9657 Jan 30 19:26 Handler.class
-rw-r--r-- 1 lukasz lukasz 3350 Jan 30 19:26 JarEntry.class
-rw-r--r-- 1 lukasz lukasz 262 Jan 30 19:26 JarEntryFilter.class
-rw-r--r-- 1 lukasz lukasz 2002 Jan 30 19:26 JarFile$1.class
-rw-r--r-- 1 lukasz lukasz 1199 Jan 30 19:26 JarFile$2.class
-rw-r--r-- 1 lukasz lukasz 1427 Jan 30 19:26 JarFile$3.class
-rw-r--r-- 1 lukasz lukasz 12697 Jan 30 19:26 JarFile.class
-rw-r--r-- 1 lukasz lukasz 1540 Jan 30 19:26 JarFileEntries$1.class
-rw-r--r-- 1 lukasz lukasz 10924 Jan 30 19:26 JarFileEntries.class
-rw-r--r-- 1 lukasz lukasz 1967 Jan 30 19:26 JarFileEntries$EntryIterator.class
-rw-r--r-- 1 lukasz lukasz 1300 Jan 30 19:26 JarFile$JarFileType.class
-rw-r--r-- 1 lukasz lukasz 672 Jan 30 19:26 JarURLConnection$1.class
-rw-r--r-- 1 lukasz lukasz 9111 Jan 30 19:26 JarURLConnection.class
-rw-r--r-- 1 lukasz lukasz 3641 Jan 30 19:26 JarURLConnection$JarEntryName.class
-rw-r--r-- 1 lukasz lukasz 1629 Jan 30 19:26 ZipInflaterInputStream.class
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org/springframework/boot/loader/util:
total 8
-rw-r--r-- 1 lukasz lukasz 4887 Jan 30 19:26 SystemPropertyUtils.class
请注意我直接用javac
致电-cp
时说我可以使用此jar(和Aclass)。
修改
Demo2Application.java的来源:
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Demo2Application {
public static void main(String[] args) {
SpringApplication.run(Demo2Application.class, args);
Aclass c = new Aclass();
}
}
jar上的jat tvf
输出:
lukasz@lukasz-XPS-L701X:~/.m2/repository/com/example/demo/0.0.1-SNAPSHOT$ jar tvf demo-0.0.1-SNAPSHOT.jar
0 Sun Feb 19 07:07:38 CET 2017 META-INF/
558 Sun Feb 19 07:07:38 CET 2017 META-INF/MANIFEST.MF
0 Sun Feb 19 07:07:38 CET 2017 BOOT-INF/
0 Sun Feb 19 07:07:38 CET 2017 BOOT-INF/classes/
0 Sun Feb 19 07:07:34 CET 2017 BOOT-INF/classes/com/
0 Sun Feb 19 07:07:34 CET 2017 BOOT-INF/classes/com/example/
267 Sun Feb 19 07:07:34 CET 2017 BOOT-INF/classes/com/example/Aclass.class
694 Sun Feb 19 07:07:34 CET 2017 BOOT-INF/classes/com/example/DemoApplication.class
0 Sun Feb 19 07:07:30 CET 2017 BOOT-INF/classes/application.properties
0 Sun Feb 19 07:07:38 CET 2017 META-INF/maven/
0 Sun Feb 19 07:07:38 CET 2017 META-INF/maven/com.example/
0 Sun Feb 19 07:07:38 CET 2017 META-INF/maven/com.example/demo/
1410 Sun Feb 19 01:01:32 CET 2017 META-INF/maven/com.example/demo/pom.xml
116 Sun Feb 19 07:07:38 CET 2017 META-INF/maven/com.example/demo/pom.properties
0 Sun Feb 19 07:07:38 CET 2017 BOOT-INF/lib/
41077 Tue Dec 13 18:07:58 CET 2016 BOOT-INF/lib/slf4j-api-1.7.22.jar
2309 Mon Jan 30 19:45:02 CET 2017 BOOT-INF/lib/spring-boot-starter-logging-1.5.1.RELEASE.jar
2290 Mon Jan 30 19:45:02 CET 2017 BOOT-INF/lib/spring-boot-starter-1.5.1.RELEASE.jar
662119 Mon Jan 30 19:31:36 CET 2017 BOOT-INF/lib/spring-boot-1.5.1.RELEASE.jar
472639 Fri Jan 20 19:57:20 CET 2017 BOOT-INF/lib/logback-core-1.1.9.jar
4596 Tue Dec 13 18:09:14 CET 2016 BOOT-INF/lib/jul-to-slf4j-1.7.22.jar
762701 Wed Jan 25 13:13:50 CET 2017 BOOT-INF/lib/spring-beans-4.3.6.RELEASE.jar
379905 Wed Jan 25 13:13:54 CET 2017 BOOT-INF/lib/spring-aop-4.3.6.RELEASE.jar
16521 Tue Dec 13 18:09:00 CET 2016 BOOT-INF/lib/jcl-over-slf4j-1.7.22.jar
263304 Wed Jan 25 13:14:04 CET 2017 BOOT-INF/lib/spring-expression-4.3.6.RELEASE.jar
23647 Tue Dec 13 18:09:06 CET 2016 BOOT-INF/lib/log4j-over-slf4j-1.7.22.jar
1136805 Wed Jan 25 13:14:18 CET 2017 BOOT-INF/lib/spring-context-4.3.6.RELEASE.jar
1117842 Wed Jan 25 13:13:44 CET 2017 BOOT-INF/lib/spring-core-4.3.6.RELEASE.jar
1038200 Mon Jan 30 19:39:22 CET 2017 BOOT-INF/lib/spring-boot-autoconfigure-1.5.1.RELEASE.jar
305150 Fri Jan 20 19:58:16 CET 2017 BOOT-INF/lib/logback-classic-1.1.9.jar
273599 Fri Feb 19 13:13:32 CET 2016 BOOT-INF/lib/snakeyaml-1.17.jar
0 Sun Feb 19 07:07:38 CET 2017 org/
0 Sun Feb 19 07:07:38 CET 2017 org/springframework/
0 Sun Feb 19 07:07:38 CET 2017 org/springframework/boot/
0 Sun Feb 19 07:07:38 CET 2017 org/springframework/boot/loader/
2415 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/LaunchedURLClassLoader$1.class
1454 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/PropertiesLauncher$ArchiveEntryFilter.class
1807 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/PropertiesLauncher$PrefixMatchingArchiveFilter.class
4599 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/Launcher.class
1165 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/ExecutableArchiveLauncher$1.class
0 Sun Feb 19 07:07:38 CET 2017 org/springframework/boot/loader/jar/
2002 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFile$1.class
9657 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/Handler.class
3350 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarEntry.class
1427 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFile$3.class
2943 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/CentralDirectoryEndRecord.class
430 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/CentralDirectoryVisitor.class
1300 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFile$JarFileType.class
10924 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFileEntries.class
12697 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFile.class
1540 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFileEntries$1.class
672 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarURLConnection$1.class
1199 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFile$2.class
262 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarEntryFilter.class
4457 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/AsciiBytes.class
4602 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/CentralDirectoryParser.class
2169 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/Bytes.class
1629 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/ZipInflaterInputStream.class
1967 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFileEntries$EntryIterator.class
306 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/FileHeader.class
3641 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarURLConnection$JarEntryName.class
9111 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarURLConnection.class
5449 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/CentralDirectoryFileHeader.class
1704 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/PropertiesLauncher$FilteredArchive$1.class
0 Sun Feb 19 07:07:38 CET 2017 org/springframework/boot/loader/data/
1531 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/data/ByteArrayRandomAccessData.class
3534 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/data/RandomAccessDataFile$DataInputStream.class
2051 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/data/RandomAccessDataFile$FilePool.class
1341 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/data/RandomAccessData$ResourceAccess.class
3390 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/data/RandomAccessDataFile.class
551 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/data/RandomAccessData.class
4698 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/LaunchedURLClassLoader.class
1533 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/JarLauncher.class
1468 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/MainMethodRunner.class
2382 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/PropertiesLauncher$FilteredArchive.class
1382 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/PropertiesLauncher$1.class
3128 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/ExecutableArchiveLauncher.class
1669 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/WarLauncher.class
0 Sun Feb 19 07:07:38 CET 2017 org/springframework/boot/loader/archive/
1749 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/JarFileArchive$EntryIterator.class
3792 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/ExplodedArchive$FileEntryIterator.class
1068 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/ExplodedArchive$FileEntry.class
1051 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/JarFileArchive$JarFileEntry.class
302 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/Archive$Entry.class
7016 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/JarFileArchive.class
4974 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/ExplodedArchive.class
906 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/Archive.class
1438 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/ExplodedArchive$FileEntryIterator$EntryComparator.class
399 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/Archive$EntryFilter.class
273 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/ExplodedArchive$1.class
16109 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/PropertiesLauncher.class
0 Sun Feb 19 07:07:38 CET 2017 org/springframework/boot/loader/util/
4887 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/util/SystemPropertyUtils.class
答案 0 :(得分:3)
你的课不在罐子里。或者更确切地说,它位于BOOT-INF/classes/com/example
目录下,而不是在com/example
目录下。
此jar文件不是可用作库的jar文件。这是一个由Spring-Boot插件创建的超级jar文件,用于包含第一个应用程序的所有依赖项和类,以及一个Spring引导加载程序,它使用自定义类加载器从超级jar加载应用程序类和依赖项。
如果jar不应该是Spring启动应用程序,而是一个简单的库,那么就不要在该项目中使用Spring-Boot插件。
如果它应该同时是一个库和一个Spring Boot应用程序(这很奇怪),那么将它分成两个项目:一个产生一个库,另一个产生一个Spring Boot应用程序,包含只是应用程序的主要类(以及不应该在库中的其他类),并且将库作为依赖项。