Skip to content

Commit 97eefb0

Browse files
christophstroblodrotbohm
authored andcommitted
spring-projects#124 - Added sample for Querydsl integration.
Move web project to web/example and add web/querydsl as a dedicated one demonstrating the QueryDSL Predicate usage in Spring MVC.
1 parent a999bed commit 97eefb0

32 files changed

+3158
-56
lines changed
File renamed without changes.

web/example/pom.xml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<artifactId>spring-data-web-example</artifactId>
6+
7+
<name>Spring Data - Web support example</name>
8+
9+
<parent>
10+
<groupId>org.springframework.data.examples</groupId>
11+
<artifactId>spring-data-web-examples</artifactId>
12+
<version>1.0.0.BUILD-SNAPSHOT</version>
13+
</parent>
14+
15+
<dependencies>
16+
17+
<dependency>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-starter-web</artifactId>
20+
</dependency>
21+
22+
<dependency>
23+
<groupId>org.springframework.boot</groupId>
24+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
25+
</dependency>
26+
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-data-jpa</artifactId>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-starter-security</artifactId>
35+
</dependency>
36+
37+
<dependency>
38+
<groupId>org.hsqldb</groupId>
39+
<artifactId>hsqldb</artifactId>
40+
</dependency>
41+
42+
</dependencies>
43+
44+
</project>

web/src/main/java/example/springdata/web/Application.java renamed to web/example/src/main/java/example/Application.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package example.springdata.web;
17-
18-
import example.springdata.web.users.Password;
19-
import example.springdata.web.users.UserManagement;
20-
import example.springdata.web.users.Username;
16+
package example;
2117

2218
import java.util.stream.IntStream;
2319

@@ -33,6 +29,10 @@
3329
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
3430
import org.springframework.security.crypto.password.PasswordEncoder;
3531

32+
import example.users.Password;
33+
import example.users.UserManagement;
34+
import example.users.Username;
35+
3636
/**
3737
* Central Spring Boot application class to bootstrap the application. Excludes Spring Security auto-configuration as we
3838
* don't need it for the example but only want to use a {@link PasswordEncoder} (see {@link #passwordEncoder()}).
@@ -41,9 +41,9 @@
4141
* {@link EnableSpringDataWebSupport}. The core aspects of the enabled functionality shown in this example are:
4242
* <ol>
4343
* <li>Automatic population of a {@link Pageable} instances from request parameters (see
44-
* {@link example.springdata.web.users.web.UserController#users(Pageable)})</li>
44+
* {@link example.users.web.UserController#users(Pageable)})</li>
4545
* <li>The ability to use proxy-backed interfaces to bind request payloads (see
46-
* {@link example.springdata.web.users.web.UserController.UserForm})</li>
46+
* {@link example.users.web.UserController.UserForm})</li>
4747
* </ol>
4848
*
4949
* @author Oliver Gierke

web/src/main/java/example/springdata/web/users/Password.java renamed to web/example/src/main/java/example/users/Password.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package example.springdata.web.users;
16+
package example.users;
1717

1818
import javax.persistence.Embeddable;
1919

web/src/main/java/example/springdata/web/users/User.java renamed to web/example/src/main/java/example/users/User.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package example.springdata.web.users;
16+
package example.users;
1717

1818
import javax.persistence.Entity;
1919
import javax.persistence.GeneratedValue;

web/src/main/java/example/springdata/web/users/UserManagement.java renamed to web/example/src/main/java/example/users/UserManagement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package example.springdata.web.users;
16+
package example.users;
1717

1818
import java.util.Optional;
1919

web/src/main/java/example/springdata/web/users/UserRepository.java renamed to web/example/src/main/java/example/users/UserRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package example.springdata.web.users;
16+
package example.users;
1717

1818
import java.util.Optional;
1919

web/src/main/java/example/springdata/web/users/Username.java renamed to web/example/src/main/java/example/users/Username.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package example.springdata.web.users;
16+
package example.users;
1717

1818
import javax.persistence.Embeddable;
1919

web/src/main/java/example/springdata/web/users/web/UserController.java renamed to web/example/src/main/java/example/users/web/UserController.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,10 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package example.springdata.web.users.web;
16+
package example.users.web;
1717

1818
import static org.springframework.validation.ValidationUtils.*;
1919

20-
import example.springdata.web.users.Password;
21-
import example.springdata.web.users.User;
22-
import example.springdata.web.users.UserManagement;
23-
import example.springdata.web.users.Username;
24-
2520
import java.util.Map;
2621

2722
import lombok.RequiredArgsConstructor;
@@ -40,6 +35,11 @@
4035
import org.springframework.web.bind.annotation.RequestMethod;
4136
import org.springframework.web.servlet.view.RedirectView;
4237

38+
import example.users.Password;
39+
import example.users.User;
40+
import example.users.UserManagement;
41+
import example.users.Username;
42+
4343
/**
4444
* A sample controller implementation to showcase Spring Data web support:
4545
* <ol>

web/src/test/java/example/springdata/web/users/AbstractIntegrationTests.java renamed to web/example/src/test/java/example/users/AbstractIntegrationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package example.springdata.web.users;
17-
18-
import example.springdata.web.Application;
16+
package example.users;
1917

2018
import org.junit.runner.RunWith;
2119
import org.springframework.boot.test.SpringApplicationConfiguration;
2220
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
2321

22+
import example.Application;
23+
2424
/**
2525
* Integration tests to bootstrap the application.
2626
*

web/src/test/java/example/springdata/web/users/UserManagementIntegrationTests.java renamed to web/example/src/test/java/example/users/UserManagementIntegrationTests.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,11 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package example.springdata.web.users;
16+
package example.users;
1717

1818
import static org.hamcrest.CoreMatchers.*;
1919
import static org.junit.Assert.*;
2020

21-
import example.springdata.web.users.Password;
22-
import example.springdata.web.users.User;
23-
import example.springdata.web.users.UserManagement;
24-
import example.springdata.web.users.Username;
25-
2621
import org.junit.Test;
2722
import org.springframework.beans.factory.annotation.Autowired;
2823

web/src/test/java/example/springdata/web/users/UserRepositoryIntegrationTests.java renamed to web/example/src/test/java/example/users/UserRepositoryIntegrationTests.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package example.springdata.web.users;
17-
18-
import example.springdata.web.users.Password;
19-
import example.springdata.web.users.User;
20-
import example.springdata.web.users.UserRepository;
21-
import example.springdata.web.users.Username;
16+
package example.users;
2217

2318
import org.junit.Test;
2419
import org.springframework.beans.factory.annotation.Autowired;

web/pom.xml

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,29 @@
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44

5-
<artifactId>spring-data-web-example</artifactId>
6-
7-
<name>Spring Data - Web support example</name>
5+
<artifactId>spring-data-web-examples</artifactId>
6+
<packaging>pom</packaging>
87

98
<parent>
109
<groupId>org.springframework.data.examples</groupId>
1110
<artifactId>spring-data-examples</artifactId>
1211
<version>1.0.0.BUILD-SNAPSHOT</version>
1312
</parent>
1413

15-
<dependencies>
16-
17-
<dependency>
18-
<groupId>org.springframework.boot</groupId>
19-
<artifactId>spring-boot-starter-web</artifactId>
20-
</dependency>
14+
<name>Spring Data Web - Examples</name>
15+
<description>Sample projects for Spring Data Web Support</description>
16+
<inceptionYear>2015</inceptionYear>
2117

22-
<dependency>
23-
<groupId>org.springframework.boot</groupId>
24-
<artifactId>spring-boot-starter-thymeleaf</artifactId>
25-
</dependency>
18+
<modules>
19+
<module>example</module>
20+
<module>querydsl</module>
21+
</modules>
2622

27-
<dependency>
28-
<groupId>org.springframework.boot</groupId>
29-
<artifactId>spring-boot-starter-data-jpa</artifactId>
30-
</dependency>
23+
<dependencies>
3124

3225
<dependency>
3326
<groupId>org.springframework.boot</groupId>
34-
<artifactId>spring-boot-starter-security</artifactId>
35-
</dependency>
36-
37-
<dependency>
38-
<groupId>org.hsqldb</groupId>
39-
<artifactId>hsqldb</artifactId>
27+
<artifactId>spring-boot-starter</artifactId>
4028
</dependency>
4129

4230
</dependencies>

web/querydsl/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Spring Data Web - QueryDSL example
2+
3+
This example shows some of the Spring Data QueryDSL integration features with Spring MVC.
4+
5+
## Quickstart
6+
7+
1. Install MongoDB (http://www.mongodb.org/downloads, unzip, run `mkdir data`, run `bin/mongod --dbpath=data`)
8+
2. Build and run the app (`mvn spring-boot:run`)
9+
3. Access the root resource (`curl http://localhost:8080/api`) and traverse hyperlinks.
10+
4. Or access app directly via its UI (`http://localhost:8080/`).
11+
12+
## Technologies used
13+
14+
- Spring Data REST & QueryDSL & Spring Data MongoDB
15+
- MongoDB
16+
- Spring Batch (to read the CSV file containing the store data and pipe it into MongoDB)
17+
- Spring Boot

0 commit comments

Comments
 (0)