Generating project in Batch mode
mvn 命令加 -X 可以看到详细过程, 可以看到卡在下载archetype-catalog.xml
解决方法很简单。
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
maven-jar-plugin maven-assembly-plugin maven-shade-plugin onejar-maven-plugin
工作需要assembly dependencies 配置, 不然会报No assembly descriptors found
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<mainClass>
com.equick.sync.job.App
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
使用mvn package assembly:single
<compilerArgs>
<arg>-Xmaxerrs</arg>
<arg>1000</arg>
<arg>-Xlint</arg>
<arg>-J-Duser.language=en_us</arg>
</compilerArgs>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<compilerArgs>
<arg>-g</arg>
</compilerArgs>
<executable>javac</executable>
<compilerVersion>1.8</compilerVersion>
</configuration>
</plugin>
// Java Application
mvn exec:exec -Dexec.executable="java" -Dexec.args="-classpath %classpath -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1044 com.mycompany.app.App"
mvn -Dtest=MySuperClassTest -Dmaven.surefire.debug test
// Spring Boot Application
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.2.1.RELEASE</version>
<configuration>
<jvmArguments>
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
</jvmArguments>
</configuration>
...
</plugin>
...
</plugins>
...
</build>
...
</project>
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
src/main/resouces和src/test/resources
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</build>
读取jar中的文件 getClass().getResourceAsStream(“3Columns.csv”)
val file = new File(getClass.getResource("zipcode_data.csv").toURI)
ClassLoader CLDR = this.getClass().getClassLoader();
InputStream inputStream = CLDR.getResourceAsStream("com/devdaily/desktopcurtain/sounds/" + soundfileName); [Java Jar file: How to read a file from a Jar file](https://alvinalexander.com/blog/post/java/read-text-file-from-jar-file/)
ClassPath根下获取。其只是通过path构造一个绝对路径,最终还是由ClassLoader获取资源。
ClassLoader获取资源。
当然这和具体的容器实现有关。
Apache Maven Project
How to Create an Executable JAR with Maven
Maven将代码及依赖打成一个Jar包的方式
Maven3种打包方式之一maven-assembly-plugin的使用
mvn assembly:single打包报错:Error reading assemblies: No assembly descriptors found
compiler:compile