0

我正在尝试编译这个项目 h__p://ross-warren.co.uk/my-twitter-clone-using-jsp-and-cassandra/

我已经下载了它,花了将近一天的时间搜索所有依赖 jar 文件,但我仍然无法运行该项目。当我进行一些搜索时,我发现了 Maven。所以我已经下载了它,在eclipse中我点击转换为maven或其他东西,我在pom.xml中添加了一些依赖记录,但我仍然无法运行该项目。jsp文件有一些错误。这些错误以前不存在。

例如在文件LogChech.jsp

    <jsp:useBean id="User"    
    class="uk.co.ross_warren.litter.stores.UserStore"
    scope="session"
    ></jsp:useBean>

我有错误Undefined type: UserStore。我不知道问题出在哪里,但我认为包有问题,因为在项目转换之前我有包中的所有java文件(至少eclipse显示包图标),现在只有正常的文件夹图标和文件夹树结构所有java 文件,但是 java 文件中的第一行是打包的东西,我认为这很好。

感谢您的帮助

编辑

这是我的 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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>Cinnamon</groupId>
  <artifactId>Cinnamon</artifactId>
  <version>0.0.1-SNAPSHOT</version>

      <dependencies>
          <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
                        <version>1.6.4</version>
              </dependency>
              <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                        <version>1.6.4</version>
              </dependency>
              <dependency>
                        <groupId>me.prettyprint</groupId>
                        <artifactId>hector-core</artifactId>
                        <version>1.0-4</version>
              </dependency>
      </dependencies>
      <packaging>war</packaging>
</project>

这是 maven 转换 http://oi39.tinypic.com/2q84o5z之前的第一张图片。

这就是它现在的样子 http://oi44.tinypic.com/14nmgyf

好的堆栈溢出说我无法提交图片,所以请使用该网址并添加 jpg 扩展名以查看图片

4

1 回答 1

1

标准的 maven 目录布局需要 java 源代码src/main/java和 web 资源在src/main/webapp. 所以你的java源代码src甚至没有被编译。这些目录可以在build您的 pom.xml 部分中配置。要设置 Web 资源的目录,您还必须配置 maven-war-plugin。

编辑:似乎您还缺少一些依赖项,下面的 pom 在命令行上编译时没有错误。我自己不是 eclipse 用户,但这也应该在 eclipse 中工作。

<?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>Cinnamon</groupId>
    <artifactId>Cinnamon</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <build>
        <directory>build</directory>
        <sourceDirectory>src</sourceDirectory>
        <outputDirectory>build/classes</outputDirectory>
        <!-- not used in your project -->
        <testSourceDirectory>srcTest</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.4</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.4</version>
        </dependency>
        <dependency>
            <groupId>me.prettyprint</groupId>
            <artifactId>hector-core</artifactId>
            <version>1.0-4</version>
        </dependency>
        <dependency>
            <groupId>org.expressme</groupId>
            <artifactId>JOpenId</artifactId>
            <version>1.08</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20090211</version>
        </dependency>
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.6.2</version>
        </dependency>
    </dependencies>
</project>
于 2012-04-19T14:57:09.810 回答