1. maven compile乱码编译不过去,检查已是utf-8无bom编码
看上去不是源代码的问题,是编译工具maven出了异常,换一个版本的jdk试一下,我以前遇到过用ant编译用jdk1.6出现异常,用jdk1.7则正常;另外你用支持UTF8的软件如记事本或网页浏览器(编码要选择utf8)等打开你的RegexUtil.java文件看一下21行是不是有乱码
2. maven总是配置不成功,是什么原因
遇到的问题和解决
错误1 :
[ERROR] Failed to execute goal on project biz_zhuhai: Could not resolve
dependencies for project biz_zhuhai:biz_zhuhai:jar:0.0.1-SNAPSHOT:
Failed to collect dependencies for [com.maywide.ibh:lib345:pom:1.0
(compile)]: Failed to read artifact descriptor for
com.maywide.ibh:lib345:pom:1.0: Could not transfer artifact
com.maywide.ibh:lib345:pom:1.0 from/to releases
(http://localhost:9888/nexus-2.0.3/content/repositories/releases):
Connection to http://localhost:9888 refused: Connection refused: connect
-> [Help 1]
解决:这是配置的url有错误或者是私服没有配好,导致构件下载时出错。如果没有jar包需要在私服里下载,可以不配置私服的,可以把setting.xml的profiles里的东西全部删除的。
错误2:[ERROR]
Failed to execute goal
org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test)
on project web_nanchang: There are test failures.
[ERROR]
[ERROR] Please refer to E:\maven\web_nanchang\target\surefire-reports for the indivial test results.
解决:这是因为测试代码时遇到错误,会停止编译。只需要在pom.xml的<project>里添加以下配置,使得测试出错不影响项目的编译。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>
错误3:
[ERROR]
Failed to execute goal
org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on
project web_nanchang: Error assembling WAR: webxml attribute is required
(or pre-existing WEB-INF/web.xml if executing in update mode) ->
[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:
解决:maven的web项目默认的webroot是在src\main\webapp。如果在此目录下找不到web.xml就抛出以上的异常。解决方法在pom.xml加入以下的配置。红色背景字体改成你网站的根目录。
<build>
<finalName>simple-webapp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>WebContent</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
错误4:
严重: The web application [/web_nanchang] registered the JBDC driver
[org.hsqldb.jdbc.JDBCDriver] but failed to unregister it when the web
application was stopped. To prevent a memory leak, the JDBC Driver has
been forcibly unregistered.
2012-4-27 10:36:49 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web
application [/web_nanchang] registered the JBDC driver
[com.mysql.jdbc.Driver] but failed to unregister it when the web
application was stopped. To prevent a memory leak, the JDBC Driver has
been forcibly unregistered.
不知道怎样解决,导致运行不了。
错误5:
把java complier改成1.6或者disabled dependency manangent后在enable消失了。
3. java eclipse导入Maven,ava环境一切已设置,发现问题maven不编译。怎么处理
先让这个maven工程转换为非maven工程。方法:右键工程--maven--Disable maven nature。在当前目录下执行命令(就是有pom.xml文件的那个目录) —— mvn eclipse:clean。最后,重新转换该工程为maven工程。右键工程--- 'Configure'--- 'Convert to Maven Project'
4. 大佬求助Maven编译java文件失败是怎么回事
问题描述:
在eclipse中build一个普通maven项目,报错,提示信息是缺少maven插件(插件名称忘了)。
原因:
可能是由于使用了eclipse自带的jre导致的,这个jre里没有tools.jar,而jdk的lib目录下有(个人理解)。
解决办法:
1、检查eclipse的配置,确保使用的不是eclipse自带的版本。
步骤:在eclipse中打开Window->Preferences->Java->Installed JREs->Add,添加自己下载并配置好的jdk(别忘了配置环境变量),我用的是jdk1.6.0_4.3。
2、然后再次编译maven项目,仍然报错,但提示信息改变了,提示的是C:\Users\Administrator.EED4VRFALFPIIBP\.m2\repository\commons-logging\commons-logging下的jar包解析失败; 3、解决方案:删除repository文件夹,确保网络畅通,重启eclipse,执行Maven->Project Update,问题解决。
注意:如果你的eclipse中配置了tomcat,那么你也需要重新选择tomcat的jdk版本,确保与前面的一致。 步骤:在eclipse中打开Window->Preferences->Server->Runtime Environment->选中你的tomcat server->Edit,在JRE这项里选择你的jdk,完成。
5. maven 项目,保存后不自动编译,每次都要clean ,install后,target下面的class文件才会变化
多半是Maven的依赖包损坏,所以停止automatical compile。可以用mvn test一下测试一下编译,看一下有哪些jar包有错误,到repository里面删了让maven重新下载一遍一般就好了。
详情请参考http://www.cnblogs.com/hejing195/p/7413837.html
6. java eclipse导入Maven工程 java环境一切已设置好,发现问题maven不编译而且弹出框内容如下:
1,先让这个maven工程转换为非maven工程。方法:右键工程--maven--Disable maven nature
2,在当前目录下执行命令(就是有pom.xml文件的那个目录) —— mvn eclipse:clean
3,重新转换该工程为maven工程。右键工程--- 'Configure'--- 'Convert to Maven Project'
试试
7. 为什么mvn编译时,不把.json文件也编译
你已经用gcc编译出目标文件了,用ar工具打包成.a文件就行了啊,示例: 如上图,假设我有test1.c,test2.c两个源文件,先使用gcc -c *.c将源文件编译成目标文件,可以看到,生成了test1.o,test2.o两个目标文件,然后,使用ar命令:ar crv libtes
8. maven pom文件编译报错
cmd可以运行mvn -v只是表示你的电脑安装好了maven。你的报错信息提示当前项目不是一个maven项目,因为找不到pom.xml文件。建议你看看 《maven实战》这本书。
9. Maven如何不编译而直接启动Jetty中上次编译好的项目
使用maven jetty 插件,并不会打成war包然后部署到jetty。。。
它是以嵌入式方式运行,jetty 直接监控某个运行目录,当文件发生变化时,如果新编译了修改的文件,它会作出相应的加载,这非常适合增量开发。