2014-01-12 33 views
3

我試圖獲取tonr和sparklr爲框架彈簧工作的示例。我遇到了maven的錯誤。這是我從https://github.com/spring-projects/spring-security-oauth獲取源代碼的地方,這是我所遵循的教程:https://github.com/spring-projects/spring-security-oauth/wiki/tutorial。注意:我已經成功完成了oauth工作,但不是oauth2。OAuth2彈簧示例sparklr和tonr

這是第一個錯誤,我得到當我運行

mvn tomcat:run 

的sparklr。

1 required artifact is missing. 

for artifact: 
    org.springframework.security.oauth:sparklr2:war:2.0.0.BUILD-SNAPSHOT 

from the specified remote repositories: 
    central (http://repo1.maven.org/maven2), 
    java.net (http://download.java.net/maven/2), 
    spring-release (http://maven.springframework.org/release), 
    spring-milestone (http://maven.springframework.org/milestone) 

這是我得到TONR錯誤

2 required artifacts are missing. 

for artifact: 
    org.springframework.security.oauth:tonr2:war:2.0.0.BUILD-SNAPSHOT 

from the specified remote repositories: 
    central (http://repo1.maven.org/maven2), 
    spring-release (http://maven.springframework.org/release), 
    spring-milestone (http://maven.springframework.org/milestone) 

這裏是sparklr

<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.springframework.security.oauth</groupId> 
     <artifactId>spring-security-oauth-parent</artifactId> 
     <version>2.0.0.BUILD-SNAPSHOT</version> 
     <relativePath>../../..</relativePath> 
    </parent> 

    <artifactId>sparklr2</artifactId> 
    <packaging>war</packaging> 
    <name>OAuth for Spring Security - Sparklr2 (OAuth 2 Provider Example)</name> 

    <profiles> 
     <profile> 
      <id>integration</id> 
      <build> 
       <plugins> 
        <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-surefire-plugin</artifactId> 
         <version>2.7.1</version> 
         <executions> 
          <execution> 
           <id>surefire-it</id> 
           <phase>integration-test</phase> 
           <goals> 
            <goal>test</goal> 
           </goals> 
           <configuration> 
            <skip>${skipTests}</skip> 
            <testFailureIgnore>false</testFailureIgnore> 
           </configuration> 
          </execution> 
         </executions> 
        </plugin> 
        <plugin> 
         <groupId>org.codehaus.mojo</groupId> 
         <artifactId>tomcat-maven-plugin</artifactId> 
         <version>1.1</version> 
         <executions> 
          <execution> 
           <id>start-tomcat</id> 
           <phase>pre-integration-test</phase> 
           <goals> 
            <goal>run</goal> 
           </goals> 
           <configuration> 
            <fork>true</fork> 
           </configuration> 
          </execution> 
         </executions> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
    </profiles> 

    <build> 
     <plugins> 
      <plugin> 
       <!--skip deploy (this is just a test module) --> 
       <artifactId>maven-deploy-plugin</artifactId> 
       <version>2.6</version> 
       <configuration> 
        <skip>true</skip> 
       </configuration> 
      </plugin> 
     </plugins> 
     <pluginManagement> 
      <plugins> 
       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>tomcat-maven-plugin</artifactId> 
        <configuration> 
         <addContextWarDependencies>true</addContextWarDependencies> 
        </configuration> 
       </plugin> 
      </plugins> 
     </pluginManagement> 
    </build> 

    <repositories> 
     <repository> 
      <id>spring-milestone</id> 
      <name>Spring Framework Milestone Repository</name> 
      <url>http://maven.springframework.org/milestone</url> 
     </repository> 
     <repository> 
      <id>spring-release</id> 
      <name>Spring Framework Release Repository</name> 
      <url>http://maven.springframework.org/release</url> 
     </repository> 
     <repository> 
      <id>java.net</id> 
      <url>http://download.java.net/maven/2</url> 
     </repository> 
    </repositories> 

    <dependencies> 
     <dependency> 
      <groupId>${project.groupId}</groupId> 
      <artifactId>spring-security-oauth2</artifactId> 
      <version>${project.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-web</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-core</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-beans</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-jdbc</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-test</artifactId> 
      <version>${spring.version}</version> 
      <scope>test</scope> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-tx</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-taglibs</artifactId> 
      <version>${spring.security.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.codehaus.jackson</groupId> 
      <artifactId>jackson-mapper-asl</artifactId> 
      <version>1.8.3</version> 
     </dependency> 

     <dependency> 
      <groupId>cglib</groupId> 
      <artifactId>cglib</artifactId> 
      <version>2.2.2</version> 
     </dependency> 

     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>javax.servlet-api</artifactId> 
      <!-- Needed for testing (with Spring 4 only), but not at runtime --> 
      <version>3.0.1</version> 
      <scope>provided</scope> 
     </dependency> 

     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>jstl</artifactId> 
      <version>1.2</version> 
     </dependency> 

     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.8.2</version> 
      <scope>test</scope> 
     </dependency> 

     <dependency> 
      <groupId>org.apache.httpcomponents</groupId> 
      <artifactId>httpclient</artifactId> 
      <version>4.3.1</version> 
      <scope>test</scope> 
     </dependency> 

    </dependencies> 

</project> 

這裏pom.xml文件是爲TONR 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.springframework.security.oauth</groupId> 
     <artifactId>spring-security-oauth-parent</artifactId> 
     <version>2.0.0.BUILD-SNAPSHOT</version> 
     <relativePath>../../..</relativePath> 
    </parent> 

    <artifactId>tonr2</artifactId> 
    <packaging>war</packaging> 
    <name>OAuth for Spring Security - Tonr2 (OAuth 2 Client Example)</name> 

    <profiles> 
     <profile> 
      <id>integration</id> 
      <build> 
       <plugins> 
        <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-surefire-plugin</artifactId> 
         <version>2.7.1</version> 
         <executions> 
          <execution> 
           <id>surefire-it</id> 
           <phase>integration-test</phase> 
           <goals> 
            <goal>test</goal> 
           </goals> 
           <configuration> 
            <skip>${skipTests}</skip> 
            <testFailureIgnore>false</testFailureIgnore> 
           </configuration> 
          </execution> 
         </executions> 
        </plugin> 
        <plugin> 
         <groupId>org.codehaus.mojo</groupId> 
         <artifactId>tomcat-maven-plugin</artifactId> 
         <version>1.1</version> 
         <executions> 
          <execution> 
           <id>start-tomcat</id> 
           <phase>pre-integration-test</phase> 
           <goals> 
            <goal>run</goal> 
           </goals> 
           <configuration> 
            <fork>true</fork> 
           </configuration> 
          </execution> 
         </executions> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
    </profiles> 

    <build> 
     <plugins> 
      <plugin> 
       <!--skip deploy (this is just a test module) --> 
       <artifactId>maven-deploy-plugin</artifactId> 
       <version>2.6</version> 
       <configuration> 
        <skip>true</skip> 
       </configuration> 
      </plugin> 
     </plugins> 
     <pluginManagement> 
      <plugins> 
       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>tomcat-maven-plugin</artifactId> 
        <configuration> 
         <addContextWarDependencies>true</addContextWarDependencies> 
        </configuration> 
       </plugin> 
      </plugins> 
     </pluginManagement> 
    </build> 

    <repositories> 
     <repository> 
      <id>spring-milestone</id> 
      <name>Spring Framework Milestone Repository</name> 
      <url>http://maven.springframework.org/milestone</url> 
     </repository> 
     <repository> 
      <id>spring-release</id> 
      <name>Spring Framework Release Repository</name> 
      <url>http://maven.springframework.org/release</url> 
     </repository> 
    </repositories> 

    <dependencies> 

     <dependency> 
      <groupId>${pom.groupId}</groupId> 
      <artifactId>sparklr2</artifactId> 
      <version>${pom.version}</version> 
      <type>war</type> 
      <scope>tomcat</scope> 
     </dependency> 

     <dependency> 
      <groupId>${project.groupId}</groupId> 
      <artifactId>spring-security-oauth2</artifactId> 
      <version>${project.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-taglibs</artifactId> 
      <version>${spring.security.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-web</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-jdbc</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-beans</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-core</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-aop</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-expression</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-tx</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.codehaus.jackson</groupId> 
      <artifactId>jackson-mapper-asl</artifactId> 
      <version>1.5.5</version> 
     </dependency> 

     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>javax.servlet-api</artifactId> 
      <version>3.0.1</version> 
      <scope>provided</scope> 
     </dependency> 

     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>jstl</artifactId> 
      <version>1.2</version> 
     </dependency> 

     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.8.2</version> 
      <scope>test</scope> 
     </dependency> 

    </dependencies> 

</project> 
+0

我有同樣的問題。我嘗試了一箇舊版本(1.0.5.RELEASE),但我得到了類似的錯誤:無法找到神器org.springframework.security.oauth:sparklr2:war:1.0.5.RELEASE在spring-milestone(http:// maven .springframework.org /里程碑) – Nereis

+0

您是否需要流血的邊緣,或者您可以嘗試切換到GIT中的1.0.X分支(這是GA版本,還是在一個點上)?然後您可以使用中央Maven存儲庫。 – JohnMark13

回答

2

可能你已經解決了這個問題,但無論如何,嘗試在根目錄中構建時出現同樣的錯誤。嘗試直接轉至..\samples\oauth2\sparklr\並運行:

mvn clean install

對於tonr也是一樣。

+0

就我而言,我只是放棄了,並使用了更適合我需求的nimbusDS實現。 – Nereis

3

第一次項目建成後,你需要運行:

mvn install -P bootstrap

bootstrap輪廓使得一些額外的資源庫。

+2

好的!我想知道爲什麼官方文件沒有提到這一點。 –

0

除了以前的說明,請使用Tomcat 7服務器通過這個命令來運行:的

mvn tomcat7:run 

代替

mvn tomcat:run 

的Tomcat 6不能正確啓動這個項目。

0

從依賴關係標記我不得不更新到2.0.8.RELEASE的spring-security-oauth2版本,因爲在Maven存儲庫中找不到SNAPSHOT版本。我希望它有幫助。

<dependency> 
     <groupId>${project.groupId}</groupId> 
     <artifactId>spring-security-oauth2</artifactId> 
     <version>2.0.8.RELEASE</version> 
    </dependency>