Skip to content

Commit f39cc7c

Browse files
# initial implementation
0 parents  commit f39cc7c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+8503
-0
lines changed

Diff for: .gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.idea
2+
*.iml
3+
target
4+
tomcat
5+
apache-*.tar.gz*

Diff for: LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2018 SouJava
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Diff for: Makefile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
default: run
4+
5+
install:
6+
chmod +x ./scripts/permissions.sh
7+
./scripts/install-tomcat.sh
8+
9+
status:
10+
ps -ef |grep tomcat
11+
12+
log:
13+
echo "============== Tail logs for Tomcat"
14+
tail -f ./tomcat/apache-tomcat-8.5.30/logs/catalina.out
15+
16+
start: stop
17+
echo "will start dev app"
18+
scripts/run.sh
19+
make log
20+
21+
browser:
22+
xdg-open http://localhost:8080/spring-security-hibernate-h2db-bootstrap/login
23+
24+
stop:
25+
echo "will stop dev app"
26+
./tomcat/apache-tomcat-8.5.30/bin/catalina.sh stop
27+
28+
29+
.PHONY: start, stop, killall, status, log

Diff for: pom.xml

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
3+
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>br.org.soujava.springmvc</groupId>
7+
<artifactId>spring-security-hibernate-h2db-bootstrap</artifactId>
8+
<packaging>war</packaging>
9+
<version>1.0.0</version>
10+
<name>spring-security-hibernate-h2db-bootstrap</name>
11+
12+
<properties>
13+
<springframework.version>4.2.5.RELEASE</springframework.version>
14+
<springsecurity.version>4.0.4.RELEASE</springsecurity.version>
15+
<hibernate.version>4.3.11.Final</hibernate.version>
16+
<mysql.connector.version>5.1.31</mysql.connector.version>
17+
</properties>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>com.h2database</groupId>
22+
<artifactId>h2</artifactId>
23+
<version>1.4.197</version>
24+
<scope>runtime</scope>
25+
</dependency>
26+
<!-- Spring -->
27+
<dependency>
28+
<groupId>org.springframework</groupId>
29+
<artifactId>spring-core</artifactId>
30+
<version>${springframework.version}</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.springframework</groupId>
34+
<artifactId>spring-web</artifactId>
35+
<version>${springframework.version}</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.springframework</groupId>
39+
<artifactId>spring-webmvc</artifactId>
40+
<version>${springframework.version}</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.springframework</groupId>
44+
<artifactId>spring-tx</artifactId>
45+
<version>${springframework.version}</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.springframework</groupId>
49+
<artifactId>spring-orm</artifactId>
50+
<version>${springframework.version}</version>
51+
</dependency>
52+
53+
<!-- Spring Security -->
54+
<dependency>
55+
<groupId>org.springframework.security</groupId>
56+
<artifactId>spring-security-web</artifactId>
57+
<version>${springsecurity.version}</version>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.springframework.security</groupId>
61+
<artifactId>spring-security-config</artifactId>
62+
<version>${springsecurity.version}</version>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.springframework.security</groupId>
66+
<artifactId>spring-security-taglibs</artifactId>
67+
<version>${springsecurity.version}</version>
68+
</dependency>
69+
70+
71+
<!-- Hibernate -->
72+
<dependency>
73+
<groupId>org.hibernate</groupId>
74+
<artifactId>hibernate-core</artifactId>
75+
<version>${hibernate.version}</version>
76+
</dependency>
77+
78+
<!-- jsr303 validation -->
79+
<dependency>
80+
<groupId>javax.validation</groupId>
81+
<artifactId>validation-api</artifactId>
82+
<version>1.1.0.Final</version>
83+
</dependency>
84+
<dependency>
85+
<groupId>org.hibernate</groupId>
86+
<artifactId>hibernate-validator</artifactId>
87+
<version>5.1.3.Final</version>
88+
</dependency>
89+
90+
<!-- SLF4J/Logback -->
91+
<dependency>
92+
<groupId>ch.qos.logback</groupId>
93+
<artifactId>logback-classic</artifactId>
94+
<version>1.1.7</version>
95+
</dependency>
96+
97+
<!-- Servlet+JSP+JSTL -->
98+
<dependency>
99+
<groupId>javax.servlet</groupId>
100+
<artifactId>javax.servlet-api</artifactId>
101+
<version>3.1.0</version>
102+
</dependency>
103+
<dependency>
104+
<groupId>javax.servlet.jsp</groupId>
105+
<artifactId>javax.servlet.jsp-api</artifactId>
106+
<version>2.3.1</version>
107+
</dependency>
108+
<dependency>
109+
<groupId>javax.servlet</groupId>
110+
<artifactId>jstl</artifactId>
111+
<version>1.2</version>
112+
</dependency>
113+
114+
</dependencies>
115+
116+
<build>
117+
<pluginManagement>
118+
<plugins>
119+
<plugin>
120+
<groupId>org.apache.maven.plugins</groupId>
121+
<artifactId>maven-compiler-plugin</artifactId>
122+
<version>3.2</version>
123+
<configuration>
124+
<source>1.8</source>
125+
<target>1.8</target>
126+
</configuration>
127+
</plugin>
128+
<plugin>
129+
<groupId>org.apache.maven.plugins</groupId>
130+
<artifactId>maven-war-plugin</artifactId>
131+
<version>2.4</version>
132+
<configuration>
133+
<warSourceDirectory>src/main/webapp</warSourceDirectory>
134+
<warName>spring-security-hibernate-h2db-bootstrap</warName>
135+
<failOnMissingWebXml>false</failOnMissingWebXml>
136+
</configuration>
137+
</plugin>
138+
</plugins>
139+
</pluginManagement>
140+
<finalName>spring-security-hibernate-h2db-bootstrap</finalName>
141+
</build>
142+
</project>

Diff for: readme.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
Description
2+
===========
3+
4+
![SouJava](https://soujavablog.files.wordpress.com/2011/01/logo-soujava-top.jpg)
5+
6+
This project is an SouJava Team effort to help you bootstrap a simple but effective app, updated, tested and that is ready so you can start coding in minutes.
7+
8+
This project will get you going with a MVC app in few minutes, you will be able to test the following technologies:
9+
10+
* Spring MVC
11+
* Spring Security
12+
* Hibernate
13+
* H2DB
14+
15+
16+
![Spring](https://slimanitech.me/assets/img/MVC.png)
17+
18+
The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications.
19+
20+
![Spring Security](https://www.journaldev.com/wp-content/uploads/2015/07/spring-secruity-modules.png)
21+
22+
In Spring Framework, “Spring Security” module is the base module for rest of the Spring Security modules.
23+
24+
![Hibernate](http://hibernate.org/images/hibernate-logo.svg)
25+
26+
Hibernate ORM is an object-relational mapping tool for the Java programming language. It provides a framework for mapping an object-oriented domain model to a relational database. Wikipedia
27+
28+
![H2DB](http://www.h2database.com/html/images/h2-logo-2.png)
29+
30+
H2 Database Engine. Welcome to H2, the Java SQL database. The main features of H2 are: Very fast, open source, JDBC API; Embedded and server modes; in-memory databases; Browser based Console application; Small footprint: around 1.5 MB jar file size ...
31+
32+
33+
# Install
34+
`make install`
35+
36+
# Run app
37+
`make start`
38+
39+
# Open [browser](http://localhost:8080/SpringMVCHibernateWithSpringSecurityExample/)
40+
`make browser`
41+
Login with username: `test` password: `test`
42+
43+
# [Tomcat manager](http://localhost:8080/manager/html)
44+
Login with username: `test` password: `test`
45+
46+
## Author
47+
Thomas Modeneis
48+
[StackOverflow](https://careers.stackoverflow.com/thomasmodeneis)
49+
[LinkedIn](https://uk.linkedin.com/in/thomasmodeneis)
50+
51+
Ivens Fernando Signorini
52+
53+
License
54+
=======
55+
56+
This module is licensed under the MIT license.

Diff for: scripts/install-tomcat.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
wget http://www.hjsnetworks.net/apache/tomcat/tomcat-8/v8.5.30/bin/apache-tomcat-8.5.30.tar.gz
4+
rm -rf ./tomcat
5+
mkdir ./tomcat
6+
tar -C ./tomcat -xzf apache-tomcat-8.5.30.tar.gz
7+
cp ./scripts/tomcat-users.xml ./tomcat/apache-tomcat-8.5.30/conf

Diff for: scripts/permissions.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
chmod +x $PWD/scripts/install-tomcat.sh
4+
chmod +x $PWD/scripts/run.sh

Diff for: scripts/run.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
TOMCAT_HOME=$PWD/tomcat/apache-tomcat-8.5.30
4+
5+
source ~/.bash_profile
6+
7+
echo "============== Building app"
8+
mvn clean && mvn install
9+
10+
echo "============== Deploying app"
11+
cp target/spring-security-hibernate-h2db-bootstrap.war $TOMCAT_HOME/webapps
12+
13+
echo "============== Starting Tomcat"
14+
$TOMCAT_HOME/bin/catalina.sh start
15+

Diff for: scripts/tomcat-users.xml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<tomcat-users xmlns="http://tomcat.apache.org/xml"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
21+
version="1.0">
22+
<!--
23+
NOTE: By default, no user is included in the "manager-gui" role required
24+
to operate the "/manager/html" web application. If you wish to use this app,
25+
you must define such a user - the username and password are arbitrary. It is
26+
strongly recommended that you do NOT use one of the users in the commented out
27+
section below since they are intended for use with the examples web
28+
application.
29+
-->
30+
<!--
31+
NOTE: The sample user and role entries below are intended for use with the
32+
examples web application. They are wrapped in a comment and thus are ignored
33+
when reading this file. If you wish to configure these users for use with the
34+
examples web application, do not forget to remove the <!.. ..> that surrounds
35+
them. You will also need to set the passwords to something appropriate.
36+
-->
37+
<!--
38+
<role rolename="tomcat"/>
39+
<role rolename="role1"/>
40+
<user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
41+
<user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
42+
<user username="role1" password="<must-be-changed>" roles="role1"/>
43+
-->
44+
<role rolename="manager-gui"/>
45+
<user username="test" password="test" roles="manager-gui"/>
46+
</tomcat-users>

0 commit comments

Comments
 (0)