Eclipse 中的" Maven - > Update Project ... "做了什么?
我有Eclipse Maven web项目,我使用Spring mvc和Spring安全性.当我试图启动它时,它并没有取决于初始化上下文:
Could not open ServletContext resource [/WEB-INF/spring-dispatcher-servlet.xml]
更多细节如下:
这是我的 web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>Web Manager</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/app-config.xml, /WEB-INF/spring/security-config.xml
</param-value>
</context-param>
<!-- Spring MVC -->
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)
这是我的 app-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context" …Run Code Online (Sandbox Code Playgroud) web-applications spring-mvc spring-security maven-eclipse-plugin
使用maven-eclipse-plugin,mvn eclipse:eclipse您可以指定eclipse 项目性质和构建器,它们将自动添加到eclipse项目中.
早期版本的m2eclipse使用了maven-eclipse-plugin的配置块,并且还允许您使用相同的机制激活自然和构建器.这似乎不再是这种情况因为a)我maven-eclipse-plugin在m2eclipse来源中找不到任何引用而b)它只是不起作用:-)
所以这是我的问题:有没有办法从pom.xml配置m2eclipse生成的eclipse项目?具体来说:项目建设者和性质,但我也对其他选项感兴趣.
我想在eclipse上安装maven插件.但是当在安装软件部分添加maven站点并开始下载并安装它时,依赖关系发生了错误.怎么解决呢?我想要一份完整的安装指南......
我正在使用Eclipse Mars和Maven(v 3.3).当我更新我的pom中的依赖项(更改版本)时,即使我右键单击我的项目,并选择"Maven" - >"更新项目",我的Eclipse-Maven项目也不会提取它.我知道这是因为我在Eclipse Java编辑器中看不到编译错误,我在命令行上使用时看到了这个错误
mvn clean install
Run Code Online (Sandbox Code Playgroud)
当我从工作区中删除项目并重新导入它时,事情就会恢复正常.然而,这是一个繁琐的过程.如何让我的Maven-Eclipse项目自动检测我的pom中的更改并适当更新项目库?
是的,在"项目"菜单中,选中"自动构建".
注意:我在这个问题的第一个版本中没有得到任何回复,因此我将其修改为更通用的...
上下文
我的项目分为几个maven模块和几个web应用程序.这是结构:
my-project
+ pom.xml
+-- commons
+-- persistence
+-- ...
+-- web-app-1
+-- web-app-2
+-- ...
Run Code Online (Sandbox Code Playgroud)
所有Web应用程序都共享公共资源,例如JS,CSS和图像文件.
web-app-X我决定创建另一个名为web-resourcesWAR项目的项目,而不是在每个项目中复制这些资源.结构如下:
my-project
+ pom.xml
+-- commons
+-- persistence
+-- ...
+-- web-app-1
+-- web-app-2
+-- ...
+-- web-resources
+-- pom.xml
+-- src/main/webapp
+-- web.xml (which is almost empty, just need to be present for Maven)
+-- web_resources
+-- css
+-- images
+-- javascript
Run Code Online (Sandbox Code Playgroud)
Maven的
在Maven 2(或Maven 3,因为我刚刚将我的项目迁移到maven 3.0.2),这个配置很容易管理,因为所有都web-app-X声明web-resources为依赖:
<groupId>foo.bar</groupId>
<artifactId>web-app-1</artifactId>
...
<dependencies>
<dependency>
<groupId>foo.bar</groupId> …Run Code Online (Sandbox Code Playgroud) 从历史上看,考虑到Flex,WTP和GWT的所有内容,我们的团队将我们的多模块Maven项目导入Eclipse是一个很大的麻烦.我们最近认为maven-eclipse-plugin可以通过生成适当的Eclipse项目文件来帮助我们.
然而,现在似乎M2Eclipse插件已被Eclipse吞噬,现在导入Maven项目似乎正在读取pom并尝试做正确的事情.
这是否意味着maven-eclipse-plugin基本上已经过时了?我们可以做些什么来帮助我们的项目以最佳方式导入Eclipse?
我已经将现有的Java项目转换为Maven项目,Maven在使用命令行时完美地构建了所有内容.
当我将相同的项目导入Eclipse并进行编译时(通过右键单击项目 - >作为Maven构建运行,它仍然可以编译而没有任何问题.
但是,我无法看到源文件夹.当我检查构建路径时,它会发出警告 - 缺少构建路径条目.
我没有使用标准,src/main/java因为我有一个预先存在的项目文件夹结构,无法更改.
这是我的pom(注意sourceDirectory标签):
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycom</groupId>
<artifactId>maven</artifactId>
<version>17.4</version>
<name>maven</name>
<properties>
<projecrt.rootDir>../../java</projecrt.rootDir>
</properties>
<build>
<finalName>re</finalName>
<sourceDirectory>${projecrt.rootDir}</sourceDirectory>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifestEntries>
<Build-Version>${buildversion}</Build-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
这是我的目录结构:
Src/java
----maven/pom.xml
----com/mycom/<...> // application code
Run Code Online (Sandbox Code Playgroud) 我想指定-Djava.library.path =./ src/main/resources的vm args以便自动获取一个dll,我想在maven中指定它,所以其他开发人员不必手动配置eclipse .
我想也许maven eclipse插件可能有帮助,所以我可以做类似的事情
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.7</version>
<configuration>
DO MAGIC HERE ???? <<-----
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但我看不到从插件中添加VM args的方法.
我已修复此问题,以便在命令行中通过maven运行我的测试
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<argLine>-Xmx768m -Xms128m -Djava.library.path=${basedir}/src/main/resources/</argLine>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我目前的解决方案是,我将不得不告诉开发人员手动将其添加到eclipse中,这看起来并不是很好.
有没有人对如何解决这个问题有任何想法.
干杯,
大卫.
我正在使用M2E与eclipse集成maven.我的单元测试资源/目录中的引用属性文件.好吧,命令行test(mvn test)中的一切都很好.但是,在Eclipse中,找不到资源.
检查Java Build Path,在那里标记所有资源条目Excluded: **.(我认为它应该只排除.java / .class文件)然后,在删除排除模式后,修复了问题.
我不确定是否应该Excluded **手动删除所有,或者我可能没有正确使用M2E.
PS项目是由进口的Existing Maven Projects.
问题:
我想在我使用m2eclipse打包的jar文件中指定主类:[右键单击] - >运行方式 - > Maven包.我还在学习Maven,从我读过的内容来看,完成这项任务的直接方法是在pom.xml中添加一个节.
以下是我在研究此问题时发现的示例:
我的问题是:可以使用文本编辑器手动编辑Eclipse/m2eclipse之外的pom.xml文件,还是应该使用m2ecplise GUI进行此配置?有几个选项卡式对话框似乎可能是此任务的候选对象,如"插件"和"构建".我查看了Sonatype的文档,找不到有关如何完成我需要做的任何详细说明.
我有点犹豫要手动编辑pom.xml因为我注意到"Effective POM"已经有很多额外的东西,包括需要添加到它的插件定义:
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
如果我理解正确,需要更改有效POM,以便插件配置如下:
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<mainClass>[name of main class]</mainClass>
<packageName>[package name]</packageName>
</manifest>
<manifestEntries>
<mode>development</mode>
<url>${pom.url}</url>
</manifestEntries>
</archive>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这是正确的吗?如果是这样,我是否通过m2eclipse执行此操作,还是应该复制所有额外的有效POM内容并使用文本编辑器将其粘贴到实际的pom.xml中?
感谢任何能够解决问题的人.
更新:我继续在文本编辑器中手动编辑pom.xml文件.当我在m2eclipse中查看Effective POM时,它会显示我放入的所有内容(我假设).我构建了jar并且正确设置了主类.
这对我来说似乎是个黑客.有没有人知道是否有办法使用m2eclipse本身进行此配置?我检查了m2eclipse选项卡,由于我对pom.xml的手动编辑(除了Effective POM选项卡),似乎没有更新任何内容.
eclipse ×10
maven ×7
java ×3
m2eclipse ×3
maven-2 ×2
classpath ×1
dependencies ×1
m2e ×1
spring-mvc ×1