How to run the spring security samples from comman

2019-08-07 01:17发布

I am trying to run the samples from http://projects.spring.io/spring-security/

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

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

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>

and running

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

Solution based on Luke's answer

$ 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

1条回答
一纸荒年 Trace。
2楼-- · 2019-08-07 01:30

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

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.

查看更多
登录 后发表回答