ing-maven常见问题解决方案。

maven

maven update project 控制JDK版本

指定maven-compiler-plugin source版本。

  • 当前project生效。
<plugins>   
    <plugin>   
        <groupId>org.apache.maven.plugins</groupId>   
        <artifactId>maven-compiler-plugin</artifactId>   
        <version>2.3.2</version>   
        <configuration>   
            <source>1.7</source>   
            <target>1.7</target>   
            <encoding>UTF-8</encoding>   
        </configuration>   
    </plugin>   
</plugins>  
  • 全局生效
    更新settings.xml,并在eclipse 中update setting[windows >preferences >maven >user settings]。
<profile>      
    <id>jdk-1.8</id>      
    <activation>      
        <activeByDefault>true</activeByDefault>      
        <jdk>1.8</jdk>      
    </activation>      
    <properties>      
        <maven.compiler.source>1.8</maven.compiler.source>      
        <maven.compiler.target>1.8</maven.compiler.target>      
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>      
    </properties>      
</profile> 

依赖本地jar包

<!-- 依赖本地jar包 -->
<dependency>
    <groupId>org.apache</groupId>
    <artifactId>test</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/[本地jar包名].jar</systemPath>
</dependency>

本地jar包位置

导出包含maven依赖的jar包

maven 封装jar包,包含maven依赖的jar包。手动copy到project目录中的jar包未能包含。maven建议用户在pom.xml中添加dependency ,从maven仓库中下载jar包 。

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.5.5</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>cn.bonc.lzy.compare_data_execel.App</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>
    </plugins>
</build>

添加provided,因为provided表明该包只在编译和测试的时候用,所以,打jar包并未整合添加了标签的依赖。

手动把jar包配置到本地仓库

mvn install:install-file -DgroupId=[groupId]  -DartifactId=[artifactId]  -Dversion=[version_id]  -Dpackaging=jar -Dfile=[jar_name]

tools

eclipse注释内容正则。

/*{1,2}[\s\S]*?*/。
//{1,2}[\s\S]*?$ 。

空白行。 ^\s*\n 。

猜你喜欢

转载自blog.csdn.net/weixin_41350766/article/details/79042744