1

我有一个将 Struts 1 与 Spring 集成的项目。我现在希望将它移植到 Maven 2 下。我已经搜索了合适的 Maven 原型,但似乎找不到合适的匹配项。有什么建议么?

谢谢!

4

2 回答 2

1

感谢 Pascal,尽管我最终决定编写自己的 pom.xml,我最初基于 AppFuse(实际上不记得我已经分支了他们的哪个原型......)

在这里,希望它可以帮助某人:

(我已经删除了专有依赖项等,所以我希望它以目前的形式保持完好......)

<?xml version="1.0" encoding="UTF-8"?>
<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>com.foo.bar</groupId>
    <artifactId>MyProject</artifactId>
    <packaging>war</packaging>
    <version>1.0.0.0-SNAPSHOT</version>
    <name>My Project</name>

    <prerequisites>
        <maven>2.0.6</maven>
    </prerequisites>


    <repositories>
        <repository>
            <id>codehaus-snapshots</id>
            <name>codehaus-snapshots</name>
            <url>http://nexus.codehaus.org/snapshots
          </url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>ignore</checksumPolicy>
            </snapshots>
        </repository>
    </repositories>


    <build>
        <defaultGoal>install</defaultGoal>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                    <wtpversion>1.5</wtpversion>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-idea-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                    <dependenciesAsLibraries>true</dependenciesAsLibraries>
                    <useFullNames>false</useFullNames>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jspc-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>jspc</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <webXml>${basedir}/target/jspweb.xml</webXml>
                            <injectString>&lt;!-- PrecompiledJSP mapping --&gt;</injectString>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.mojo.jspc</groupId>
                        <artifactId>jspc-compiler-tomcat5</artifactId>
                        <version>2.0-alpha-3</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <webXml>${basedir}/target/jspweb.xml</webXml>
                    <dependentWarExcludes>**/jdbc.properties,**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**</dependentWarExcludes>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>
                            <tasks>
                                <property name="project.ant.conf"
                                    value="${project.build.sourceDirectory}/../conf" />
                                <property name="project.ant.resources"
                                    value="${project.build.sourceDirectory}/../resources" />
                                <property name="project.ant.package"
                                    value="${project.build.sourceDirectory}/../package" />
                                <property name="project.ant.deploy"
                                    value="${project.build.sourceDirectory}/../../deployment" />
                                <property name="project.ant.target.deploy" value="${project.build.directory}/deployment" />

                                <copy todir="${project.ant.target.deploy}">
                                    <fileset dir="${project.ant.deploy}">
                                        <include name="**/*" />
                                    </fileset>
                                </copy>

                                <copy todir="${project.ant.target.deploy}/conf">
                                    <fileset dir="${project.ant.conf}">
                                        <include name="**/*.properties" />
                                    </fileset>
                                </copy>

                                <copy todir="${project.ant.target.deploy}/resources">
                                    <fileset dir="${project.ant.resources}">
                                        <include name="**/*" />
                                    </fileset>
                                </copy>

                                <move
                                    file="${project.build.directory}/${project.artifactId}-${project.version}.${project.packaging}"
                                    todir="${project.ant.target.deploy}/webapps" />
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin><!-- Thanks due to Pascal Thivent @ http://stackoverflow.com/users/70604/pascal-thivent -->
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2-beta-5</version>
                <configuration>
                    <descriptors>
                        <descriptor>${basedir}/src/main/package/zip.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                    <id>make-assembly</id> <!-- this is used for inheritance merges -->
                    <phase>package</phase> <!-- append to the packaging phase. -->
                    <goals>
                        <goal>single</goal> <!-- goals == mojos -->
                    </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <version>1.0-beta-1</version>
                <configuration>
                    <!-- Required -->
                    <path>/MyProject</path>
                    <warDirectory>${project.build.directory}/${project.build.finalName}</warDirectory>

                    <!-- Optional -->
                    <additionalConfigFilesDir>${basedir}/src/main/tomcatconf</additionalConfigFilesDir>
                    <contextFile>${project.build.directory}/${project.build.finalName}/META-INF/context.xml</contextFile>

                    <port>${cargo.port}</port>
                    <systemProperties>
                        <log4j.configuration>file:${basedir}/src/main/conf/log4j.properties.dev</log4j.configuration>
                    </systemProperties>
                </configuration>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/conf</directory>
                <includes>
                    <include>MessageResources.properties</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/webapp/velocity/templates</directory>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
            <testResource>
                <directory>src/main/webapp</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </testResource>
        </testResources>
    </build>

    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <version>${jsp.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>${servlet.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity</artifactId>
            <version>${velocity.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-struts</artifactId>
            <version>${spring.struts.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>${org.springframework.spring.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>${taglibs.standard.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>xalan</groupId>
            <artifactId>xalan</artifactId>
            <version>${xalan.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <reporting>
        <plugins>
            <plugin>
                <artifactId>maven-changes-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-jxr-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-pmd-plugin</artifactId>
                <configuration>
                    <linkXref>true</linkXref>
                    <targetJdk>1.6</targetJdk>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-report-plugin</artifactId>
            </plugin>
        </plugins>
    </reporting>


    <properties>
        <!-- Application settings -->
        <copyright.year>2010</copyright.year>

        <web.framework>spring</web.framework>

        <!-- Framework dependency versions -->
        <spring.version>2.5.6</spring.version>
        <spring.struts.version>2.0.6</spring.struts.version>
        <org.springframework.spring.version>2.5</org.springframework.spring.version>
        <velocity.version>1.6.2</velocity.version>

        <!-- 3rd Party dependency version  -->
        <log4j.version>1.2.15</log4j.version>
        <jstl.version>1.1.2</jstl.version>
        <jdom.version>1.1</jdom.version>
        <taglibs.standard.version>1.1.2</taglibs.standard.version>
        <xalan.version>2.7.1</xalan.version>

        <!-- Testing dependency versions -->
        <jsp.version>2.0</jsp.version>
        <junit.version>4.4</junit.version>
        <servlet.version>2.4</servlet.version>

        <!-- Cargo settings -->
        <cargo.container>tomcat6x</cargo.container>
        <cargo.container.home>${env.CATALINA_HOME}</cargo.container.home>
        <cargo.container.url>http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.14/bin/apache-tomcat-6.0.14.zip</cargo.container.url>
        <cargo.host>localhost</cargo.host>
        <cargo.port>8081</cargo.port>
        <cargo.wait>false</cargo.wait>
    </properties>
</project>
于 2010-03-31T08:12:12.563 回答
0

我不确定您到底在寻找什么(毕竟,Struts + Spring 应用程序只是一个 web 应用程序),但 Maven 2 有一个Struts 1 Blank Archetype

$ mvn archetype:create                                \
      -DarchetypeGroupId=org.apache.struts            \
      -DarchetypeArtifactId=struts-archetype-blank    \
      -DarchetypeVersion=1.3.5                        \
      -DgroupId=com.example                           \
      -DpackageName=com.example.projectname           \
      -DartifactId=my-webapp

我认为您不会为 Struts 1 + Spring 2.5 找到任何东西(至少,据我所知)。

于 2010-02-01T09:22:49.587 回答