maven编译问题
Ⅰ maven编译项目报错了
看看maven的本地仓库相应的编译插件有没有问题。
我的本地仓库中的依赖包都是用的阿里云的镜像仓库下载的。
Ⅱ 怎样解决maven里编译时包的依赖有关问题
一、导出到默认目录 targed/dependency
从Maven项目中导出项目依赖的jar包:进入工程pom.xml 所在的目录下,执行如下命令:
mvn dependency:-dependencies
或在eclipse中,选择项目的pom.xml文件,点击右键菜单中的Run As,见下图红框中,在弹出的Configuration窗口中,输入 dependency:-dependencies后,点击运行
maven项目所依赖的jar包会导出到targed/dependency目录中。
二、导出到自定义目录中
在maven项目下创建lib文件夹,输入以下命令:
mvn dependency:-dependencies -DoutputDirectory=lib
maven项目所依赖的jar包都会复制到项目目录下的lib目录下
三、设置依赖级别
同时可以设置依赖级别,通常使用compile级别
mvn dependency:-dependencies -DoutputDirectory=lib -DincludeScope=compile
Ⅲ maven编译工程war包、各位大大有谁遇到类似问题
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.abc.ABCTest</mainClass> -->入口类名
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id></id>
<phase>install</phase>
<goals>
<goal>-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory> -->拷贝所以依赖存放位置
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Ⅳ maven 编译项目问题
maven项目编译的标准输出路径就是mavenProject/target/classes, 项目右键 build path--configure build path--java build path--source,把default output folder改成mavenProject/target/classes,在菜单栏project下把自动编译打勾。
Ⅳ maven编译错误 d lifecycle pha se or a goal
一、问题描述
Windows下,需要将jar包手动导入Maven本地仓库,使用Power Shell运行命令:
mvn install:install-file -Dfile="E:\Tools\ipdatabase\target\ipdatabase-1.0-SNAPSHOT.jar" -DgroupId=com.ggstar -DartifactId=ipdatabase -Dversion=1.0 -Dpackaging=jar
报错:
[ERROR] Unknown lifecycle phase ".ggstar". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [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/
二、问题原因
Power Shell的命令和cmd的命令有不一样,这个命令在cmd是可以实行的。
三、解决方法
1.在cmd命令行中执行
在含pom.xml文件的根路径下打开cmd命令行,然后输入命令
mvn install:install-file -Dfile="E:\Tools\ipdatabase\target\ipdatabase-1.0-SNAPSHOT.jar" -DgroupId=com.ggstar -DartifactId=ipdatabase -Dversion=1.0 -Dpackaging=jar
然后打包成功:
[INFO] Building ipdatabase 1.0-SNAPSHOT[INFO] ------------------------------------------------------------------------[INFO][INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ ipdatabase ---[INFO] Installing E:\Tools\ipdatabase\target\ipdatabase-1.0-SNAPSHOT.jar to E:\Tools\apache-maven-3.3.9\Repository\com\ggstar\ipdatabase\1.0\ipdatabase-1.0.jar[INFO] Installing C:\Users\ADMINI~1\AppData\Local\Temp\mvninstall4727202787532518137.pom to E:\Tools\apache-maven-3.3.9\Repository\com\ggstar\ipdatabase\1.0\ipdatabase-1.0.pom[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 1.703 s[INFO] Finished at: 2018-10-05T20:40:36+08:00[INFO] Final Memory: 8M/123M[INFO] ------------------------------------------------------------------------
2.在Power Shell下
参数需要添加单引号'',如下命令即可
mvn install:install-file -Dfile="E:\Tools\ipdatabase\target\ipdatabase-1.0-SNAPSHOT.jar" '-DgroupId=com.ggstar' '-DartifactId=ipdatabase' '-Dversion=1.0' '-Dpackaging=jar'
还有不懂的可以关注私聊我,本人10年java开发经验,相信可以帮助你成为一个优秀的java程序员
Ⅵ 用maven编译项目时出现如下问题
在/etc/profile配置java的环境变量: 你的mvn 项目是用哪个版本的jdk.,就要配置那个版本的jdk。
强制保存文件命令:w !sudo tee %
此时在进入项目执行:$ git pull origin master
继续mvn clean install