我在这里阅读了关于以前的maven问题的一些有用的帖子,我目前对学习maven非常感兴趣(因为我喜欢它,因为我的老板需要我)。我目前正在阅读[这本] [1]一书,我正在通过例子工作。它是一本简单明了的书,但其内部存在一些错误(琐碎的),但对于像我这样的新手来说,很难发现,一旦发现它可以很容易地修复。有没有其他书更好地理解从上到下的maven?问题的关于maven的问题
第二部分是关于一个例子,这本书,也许一个简单的解释就解决了我的怀疑。
这是事情,我做了一个simple-weather
项目在Java中检索从雅虎天气服务器的天气条件,给予特定的邮政编码,它返回天气信息。
然后我做了一个'simple-webapp'(带有maven以及上面我忘记提到的那个),这基本上是一个web项目,它有一些默认的servlet已经与maven一起使用,它什么都不做。我想要将这两个项目合并为一个,所以我创建了一个包含2个模块的pom.xml,其中包含1个用于检索信息(java项目)和其他信息以将其显示在Web(Web应用程序)上的信息。
我在结束了一切工作,但这里是奇怪的事情。如果我做的webapp显示任何字符串“name”可以说,然后独立打造它,它不正是打印字符串。但是,当我把webapp放在“父项目”中,并将此字符串更改为“name1”并将其构建为一个partent-project子模块时。没有任何更改..
因此,我回到了这一点,因为简单的webapp是依赖于简单的天气我不能再建立它自己,所以现在,如果我想对webapp做一些更改..修改webapp的“父项目”之外建立它然后粘贴它回来到父项目,然后更改将适用,为什么是这样,为什么我不能直接更改servlet内容/或在webapp中添加另一个作为“父项目”的一部分?
谢谢。我知道它长而枯燥的问题,但我只是想学的东西,有没有更好的地方,要求比这里:d
编辑 - 下面是POM文件每个项目:
1.简单母体的pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-parent</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<name>Multi Chapter Simple Parent Project</name>
<modules>
<module>simple-weather</module>
<module>simple-webapp</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
2.简单全天候的pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-parent</artifactId>
<version>1.0</version>
</parent>
<artifactId>simple-weather</artifactId>
<packaging>jar</packaging>
<name>Multi Chapter Simple Weather API</name>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
3.简单的webapp的pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-parent</artifactId>
<version>1.0</version>
</parent>
<artifactId>simple-webapp</artifactId>
<packaging>war</packaging>
<name>simple-webapp Maven Webapp</name>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-weather</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<build>
<finalName>simple-webapp</finalName>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
请解释您运行的目标以及从哪里运行。 – 2010-02-05 16:38:54
我正在运行,maven clean,然后从父pom.xml安装maven – 2010-02-08 09:36:43