maven 使用

maven-enforcer-plugin (goal “enforce”) is ignored by m2e.

http://blog.csdn.net/jdwl20090304/article/details/40107269

maven打包可运行的JAR

http://blog.163.com/coffee_hc/blog/static/4485331920121274422988/

java运行jar命令提示没有主清单属性
http://jingyan.baidu.com/article/db55b60990f6084ba30a2fb8.html

打包时跳过test
http://www.cnblogs.com/lixuwu/p/5941363.html

解决Maven报Plugin execution not covered by lifecycle configuration

http://blog.csdn.net/xxd851116/article/details/25197373

Java/Scala混合项目maven打包

mvn clean scala:compile compile package

Maven打包过程中跳过测试
http://blog.csdn.net/redstarofsleep/article/details/46518585

maven冲突

package macros contains object and package with same name:blackbox one of them needs to be removed from classpath

这有可能是scala中的Object和添加的依赖有冲突,比如,本次遇到的冲突就是和下面的依赖有冲突,跟scope标签没关系,也跟scala编译器的配置没关系

<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-mllib_2.10 -->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-mllib_2.10</artifactId>
            <version>2.2.0</version>
            <scope>provided</scope>
        </dependency>

请使用 -source 7 或更高版本以启用 diamond 运算符

<plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
                <executions>
                    <execution>
                        <id>default-compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-testCompile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

maven-assembly-plugin

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>org.neo4j.test.Neo4jTest</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <!-- <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions> -->
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>jar-with-dependencies</id>
                        <phase>package</phase>
                        <!-- <goals>
                            <goal>single</goal>
                        </goals> -->
                        <configuration>
                            <descriptors>
                                <descriptor>src/assembly/jar-assembly.xml</descriptor>
                            </descriptors>
                            <archive>
                                <manifest>
                                    <addClasspath>true</addClasspath>
                                    <classpathPrefix>lib/</classpathPrefix>
                                    <mainClass>org.neo4j.test.Neo4jTest</mainClass>
                                </manifest>
                            </archive>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

maven 打包后,通过可以得到src/main/resources下的资源,这是将src/main/resources下的资源打入jar包后,通过以下方法得到

PropertyConfigurator.configure(this.getClass().getClassLoader().getResource("log4j.properties"));

如果maven打包后,没有把src/main/resources下的资源打入jar包,从另外的配置文件读取,是这样的,读取的jar里的

String path="conf/log4j.properties";
InputStream in=this.getClass().getClassLoader().getResourceAsStream(path);

这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值