如何从命令行(而不是从STS)运行spring安全示例? [英] How to run the spring security samples from command line (instead of from STS)?

查看:145
本文介绍了如何从命令行(而不是从STS)运行spring安全示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行 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

this guide explains how to run the insecuremvc sample from Spring Tool Suite (STS): http://docs.spring.io/spring-security/site/docs/3.2.x/guides/hellomvc.html

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

How can I run the sample from the command line (instead of from STS)?

我尝试将以下内容添加到pom.xml-> project/build/plugins:

I've tried adding the following to pom.xml -> project/build/plugins:

  <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.


基于卢克答案的解决方案

$ 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

推荐答案

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

I'm not sure what the problem here is, but if you are just interested in running Spring Security samples, there are lots in the project source tree itself.

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

将为您提供正在运行的服务器.您也可以使用本地gradle安装代替项目中包含的包装器.最初的构建将花费一些时间,但是之后会有很多示例项目可以在其中运行,其中显示了XML名称空间和Java配置选项.

will give you a running server. You can also use a local gradle installation instead of the wrapper included in the project. The initial build will take a while, but there are lots of sample projects in there which you can run afterwards, showing both XML namespace and Java configuration options.

这篇关于如何从命令行(而不是从STS)运行spring安全示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆