【问题标题】:How to run the spring security samples from command line (instead of from STS)?如何从命令行(而不是从 STS)运行 spring 安全示例?
【发布时间】:2014-06-14 00:48:19
【问题描述】:

我正在尝试从http://projects.spring.io/spring-security/ 运行样本

本指南解释了如何从 Spring Tool Suite (STS) 运行 insecuremvc 示例: http://docs.spring.io/spring-security/site/docs/3.2.x/guides/hellomvc.html

如何从命令行(而不是从 STS)运行示例?

我尝试将以下内容添加到 pom.xml -> 项目/构建/插件:

  <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
      <path>/</path>
      <uriEncoding>UTF-8</uriEncoding>
      <hostName>localhost</hostName>
      <port>8080</port>
      <update>true</update>
      <useTestClasspath>true</useTestClasspath>
    </configuration>
  </plugin>

并运行

$ mvn package tomcat7:run

but browsing http://localhost:8080/sample/
I get a HTTP Status 400 - The request sent by the client was syntactically incorrect.

基于 Luke 的回答的解决方案

$ git clone https://github.com/spring-projects/spring-security.git
$ cd spring-security/samples/insecuremvc
$ ../../gradlew tasks
# this shows several defined tasks, tomcatRunWar among them
$ ../../gradlew tomcatRunWar

【问题讨论】:

    标签: maven spring-mvc spring-security


    【解决方案1】:

    我不确定这里的问题是什么,但如果您只是对运行 Spring Security 示例感兴趣,项目源代码树本身就有很多。

    $ git clone git@github.com:spring-projects/spring-security.git
    $ cd spring-security/samples/tutorial-xml
    $ ../../gradlew jettyRun
    

    会给你一个正在运行的服务器。您还可以使用本地 gradle 安装,而不是项目中包含的包装器。初始构建需要一段时间,但其中有很多示例项目可供您随后运行,显示 XML 命名空间和 Java 配置选项。

    【讨论】:

    • 在 tutorial-xml 上运行此命令有效,但在 spring-security/samples/insecuremvc 上运行则无效。我想使用这个示例来遵循本指南:docs.spring.io/spring-security/site/docs/3.2.x/guides/… 但是,运行“../../gradlew 任务”,我看到有任务“tomcatRunWar”,并且正在运行“../. ./gradlew tomcatRunWar" 确实有效。谢谢!
    • 是的,看起来该示例使用了 tomcat 插件 - 您可以检查根项目中 gradle 目录中的导入以查看内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-01
    • 2020-05-29
    • 1970-01-01
    • 2012-11-30
    • 2016-10-13
    相关资源
    最近更新 更多