0

我正在使用 eclipse 创建一个 twitter 应用程序,但在 maven 依赖项中找不到 TwitterTemplate。这是我的pom文件。

<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>ddd</groupId>
  <artifactId>assignment7</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>assignment7</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
<repositories>
<repository>
    <id>springsource-repo</id>
    <name>SpringSource Repository</name>
    <url>http://repo.springsource.org/release</url>
    </repository>
</repositories>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-context</artifactId>
 <version>3.1.1.RELEASE</version>
</dependency> 
<dependency>
 <groupId>org.springframework.social</groupId>
 <artifactId>spring-social-core</artifactId>
 <version>1.0.1.RELEASE</version>
</dependency> 
  </dependencies>
</project>

到目前为止,这是我在eclipse上写的

package ddd.assignment7;
public class App {
    public static void main( String[] args )
    {   
        String consumerKey = "xxx"; // The application's consumer key
        String consumerSecret = "xxx"; // The application's consumer secret
        String accessToken = "xxx"; // The access token granted after OAuth authorization
        String accessTokenSecret = "xxx"; // The access token secret granted after OAuth authorization
        Twitter twitter = new TwitterTemplate(consumerKey, consumerSecret, accessToken, accessTokenSecret);


}
}

我需要的是 TwitterTemplate 类,但在 Maven 依赖项中找不到它。我应该怎么办?我对java很陌生,我真的很困惑我应该做什么。

4

1 回答 1

0

TwitterTemplate打包到单独的工件spring-social-twitter中,因此要使其可用,请将以下内容添加到您的pom.xml

<dependency>
    <groupId>org.springframework.social</groupId>
    <artifactId>spring-social-twitter</artifactId>
    <version>1.0.1.RELEASE</version>
</dependency>

(顺便说一句,1.0.2.RELEASE 可用)

于 2012-04-28T21:23:37.100 回答