初学SSH + maven的那点事

    xiaoxiao2025-07-11  26

    1. 项目构建

    2. 遇到过得的问题

    one:maven项目Java resources 上面有个红叉但是代码里面并没有什么报错

    解决办法:1.通过: windows菜单 -> show view/other 菜单 -> other菜单 在弹出的窗口中,搜索 Problems窗口。 2.然后运行程序/或者在Problems窗口中,你会发现 红色的警告,这些就是反映的错误,修复它们,即可。

    two:误删了target文件

    解决办法: 1.进入本地仓库的repository\org\apache\maven\plugins文件下

    2.删除所有plugin

    3.重启eclipse

    4.重新clean 、install

    three: Maven打包web项目报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if

    原因:maven的web项目默认的webroot是在src\main\webapp。如果在此目录下找不到web.xml就抛出以上的异常 解决办法: 1.将webroot修改为webapp 2.在pom.xml中指定web.xml,如下:

    <build> <finalName>web-app-name</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.2</version> <configuration> <webXml>webapp\WEB-INF\web.xml</webXml> </configuration> </plugin> </plugins> </build>

    four: maven clean报maven-clean-plugin:2.5 one of its dependencies could not be 下载

    经历了反复的clean-build、maven force update及各种可能想得到的操作,某些依赖包依然无法下载。 解决办法:在settings.xml中加入如下代码

    <mirrors> <mirror> <id>nexus</id> <mirrorOf>central</mirrorOf> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </mirror> </mirrors>

    four: maven clean报maven-clean-plugin:2.5 one of its dependencies could not be 下载

    原因:hibernate.hql是对类进行查询的 解决办法:纠正hql语句,将表名改为类名,EMPLOYEES是表名,Employee是类名,所以要改成 session.createQuery(“from Employee”).list().iterator();

    **

    six: maven-clean-plugin:2.5 one of its dependencies could not be 下载

    setting加入如下配置 **

    <mirrors> <mirror> <id>nexus</id> <name>internal nexus repository</name> <!-- <url>http://192.168.1.100:8081/nexus/content/groups/public/</url>--> <url>http://repo.maven.apache.org/maven2</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors>
    最新回复(0)