Migrated modules using parent-spring-5:
ethereum persistence-modules/spring-data-elasticsearch persistence-modules/spring-data-mongodb spring-dispatcher-servlet spring-mvc-forms-jsp spring-mvc-java
This commit is contained in:
parent
39bfa04d11
commit
1ca15e5919
@ -7,10 +7,10 @@
|
||||
<name>ethereum</name>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-spring-5-1</artifactId>
|
||||
<artifactId>parent-spring-5</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-spring-5-1</relativePath>
|
||||
<relativePath>../parent-spring-5</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@ -37,17 +37,17 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>${springframework.version}</version>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>${springframework.version}</version>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
<version>${springframework.version}</version>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Ethereum -->
|
||||
@ -123,12 +123,12 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>${springframework.version}</version>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${springframework.version}</version>
|
||||
<version>${spring.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@ -212,7 +212,6 @@
|
||||
<tomcat.version>8.5.4</tomcat.version>
|
||||
<ethereumj-core.version>1.5.0-RELEASE</ethereumj-core.version>
|
||||
<web3j.core.version>3.3.1</web3j.core.version>
|
||||
<springframework.version>5.0.5.RELEASE</springframework.version>
|
||||
<spring.boot.version>1.5.6.RELEASE</spring.boot.version>
|
||||
<mockito.version>2.21.0</mockito.version>
|
||||
<jackson-databind.version>2.9.7</jackson-databind.version>
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-spring-5-1</artifactId>
|
||||
<artifactId>parent-spring-5</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-spring-5-1</relativePath>
|
||||
<relativePath>../../parent-spring-5</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -30,6 +30,13 @@ import org.junit.Test;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
/**
|
||||
*
|
||||
* This Manual test requires:
|
||||
* * Elasticsearch instance running on host
|
||||
* * with cluster name = elasticsearch
|
||||
*
|
||||
*/
|
||||
public class ElasticSearchManualTest {
|
||||
private List<Person> listOfPersons = new ArrayList<>();
|
||||
private Client client = null;
|
||||
|
@ -31,9 +31,17 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import com.baeldung.spring.data.es.config.Config;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
*
|
||||
* This Manual test requires:
|
||||
* * Elasticsearch instance running on host
|
||||
* * with cluster name = elasticsearch
|
||||
* * and further configurations
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = Config.class)
|
||||
public class GeoQueriesIntegrationTest {
|
||||
public class GeoQueriesManualTest {
|
||||
|
||||
private static final String WONDERS_OF_WORLD = "wonders-of-world";
|
||||
private static final String WONDERS = "Wonders";
|
@ -27,9 +27,16 @@ import com.baeldung.spring.data.es.model.Article;
|
||||
import com.baeldung.spring.data.es.model.Author;
|
||||
import com.baeldung.spring.data.es.service.ArticleService;
|
||||
|
||||
/**
|
||||
*
|
||||
* This Manual test requires:
|
||||
* * Elasticsearch instance running on host
|
||||
* * with cluster name = elasticsearch
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = Config.class)
|
||||
public class ElasticSearchIntegrationTest {
|
||||
public class ElasticSearchManualTest {
|
||||
|
||||
@Autowired
|
||||
private ElasticsearchTemplate elasticsearchTemplate;
|
@ -41,9 +41,16 @@ import com.baeldung.spring.data.es.model.Article;
|
||||
import com.baeldung.spring.data.es.model.Author;
|
||||
import com.baeldung.spring.data.es.service.ArticleService;
|
||||
|
||||
/**
|
||||
*
|
||||
* This Manual test requires:
|
||||
* * Elasticsearch instance running on host
|
||||
* * with cluster name = elasticsearch
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = Config.class)
|
||||
public class ElasticSearchQueryIntegrationTest {
|
||||
public class ElasticSearchQueryManualTest {
|
||||
|
||||
@Autowired
|
||||
private ElasticsearchTemplate elasticsearchTemplate;
|
@ -7,9 +7,15 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.baeldung.spring.data.es.config.Config;
|
||||
|
||||
/**
|
||||
*
|
||||
* This Manual test requires:
|
||||
* * Elasticsearch instance running on host
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = Config.class)
|
||||
public class SpringContextIntegrationTest {
|
||||
public class SpringContextManualTest {
|
||||
|
||||
@Test
|
||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
@ -6,9 +6,9 @@
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-spring-5-1</artifactId>
|
||||
<artifactId>parent-spring-5</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-spring-5-1</relativePath>
|
||||
<relativePath>../../parent-spring-5</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@ -96,7 +96,6 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring.version>5.1.0.RELEASE</spring.version>
|
||||
<org.springframework.data.version>2.1.2.RELEASE</org.springframework.data.version>
|
||||
<querydsl.version>4.1.4</querydsl.version>
|
||||
<mysema.maven.version>1.1.3</mysema.maven.version>
|
||||
|
@ -44,6 +44,12 @@ import com.mongodb.MongoClient;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
|
||||
/**
|
||||
*
|
||||
* This test requires:
|
||||
* * mongodb instance running on the environment
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
public class ZipsAggregationLiveTest {
|
||||
|
@ -31,6 +31,12 @@ import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBObject;
|
||||
import com.mongodb.client.gridfs.model.GridFSFile;
|
||||
|
||||
/**
|
||||
*
|
||||
* This test requires:
|
||||
* * mongodb instance running on the environment
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration("file:src/main/resources/mongoConfig.xml")
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class GridFSLiveTest {
|
||||
|
@ -24,6 +24,12 @@ import com.baeldung.config.MongoConfig;
|
||||
import com.baeldung.model.EmailAddress;
|
||||
import com.baeldung.model.User;
|
||||
|
||||
/**
|
||||
*
|
||||
* This test requires:
|
||||
* * mongodb instance running on the environment
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
public class DocumentQueryLiveTest {
|
||||
|
@ -16,6 +16,12 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*
|
||||
* This test requires:
|
||||
* * mongodb instance running on the environment
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = SimpleMongoConfig.class)
|
||||
public class MongoTemplateProjectionLiveTest {
|
||||
|
@ -27,6 +27,12 @@ import com.baeldung.config.MongoConfig;
|
||||
import com.baeldung.model.EmailAddress;
|
||||
import com.baeldung.model.User;
|
||||
|
||||
/**
|
||||
*
|
||||
* This test requires:
|
||||
* * mongodb instance running on the environment
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
public class MongoTemplateQueryLiveTest {
|
||||
|
@ -15,6 +15,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* This test requires:
|
||||
* * mongodb instance running on the environment
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
public class ActionRepositoryLiveTest {
|
||||
|
@ -7,6 +7,12 @@ import org.junit.Before;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
|
||||
/**
|
||||
*
|
||||
* This test requires:
|
||||
* * mongodb instance running on the environment
|
||||
*
|
||||
*/
|
||||
public class BaseQueryLiveTest {
|
||||
|
||||
@Autowired
|
||||
|
@ -15,8 +15,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.querydsl.core.types.Predicate;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* This test requires:
|
||||
* * mongodb instance running on the environment
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
public class DSLQueryLiveTest extends BaseQueryLiveTest {
|
||||
|
@ -12,6 +12,12 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
*
|
||||
* This test requires:
|
||||
* * mongodb instance running on the environment
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
public class JSONQueryLiveTest extends BaseQueryLiveTest {
|
||||
|
@ -12,6 +12,12 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
*
|
||||
* This test requires:
|
||||
* * mongodb instance running on the environment
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
public class QueryMethodsLiveTest extends BaseQueryLiveTest {
|
||||
|
@ -23,6 +23,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import com.baeldung.config.MongoConfig;
|
||||
import com.baeldung.model.User;
|
||||
|
||||
/**
|
||||
*
|
||||
* This test requires:
|
||||
* * mongodb instance running on the environment
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
public class UserRepositoryLiveTest {
|
||||
|
@ -13,6 +13,12 @@ import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
*
|
||||
* This test requires:
|
||||
* * mongodb instance running on the environment
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
public class UserRepositoryProjectionLiveTest {
|
||||
|
@ -12,6 +12,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import com.baeldung.config.MongoReactiveConfig;
|
||||
import com.baeldung.model.User;
|
||||
|
||||
/**
|
||||
*
|
||||
* This test requires:
|
||||
* * mongodb instance running on the environment
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoReactiveConfig.class)
|
||||
public class MongoTransactionReactiveLiveTest {
|
||||
|
@ -24,6 +24,12 @@ import org.springframework.transaction.support.TransactionTemplate;
|
||||
import com.baeldung.config.MongoConfig;
|
||||
import com.baeldung.model.User;
|
||||
|
||||
/**
|
||||
*
|
||||
* This test requires:
|
||||
* * mongodb instance running on the environment
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
public class MongoTransactionTemplateLiveTest {
|
||||
|
@ -24,6 +24,12 @@ import com.baeldung.model.User;
|
||||
import com.baeldung.repository.UserRepository;
|
||||
import com.mongodb.MongoCommandException;
|
||||
|
||||
/**
|
||||
*
|
||||
* This test requires:
|
||||
* * mongodb instance running on the environment
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
|
@ -1,3 +1,4 @@
|
||||
### Relevant Articles:
|
||||
- [A Guide to Flips for Spring](http://www.baeldung.com/flips-spring)
|
||||
- [Configuring a Hikari Connection Pool with Spring Boot](https://www.baeldung.com/spring-boot-hikari)
|
||||
- [Spring JSON-P with Jackson](http://www.baeldung.com/spring-jackson-jsonp)
|
||||
|
@ -52,6 +52,21 @@
|
||||
<!-- Check for the most recent available version: https://projectlombok.org/changelog.html -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>jstl</artifactId>
|
||||
</dependency>
|
||||
<!-- Provided -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-jasper</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@ -71,6 +86,7 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<start-class>com.baeldung.flips.ApplicationConfig</start-class>
|
||||
<flips-web.version>1.0.1</flips-web.version>
|
||||
<lombok.version>1.16.18</lombok.version>
|
||||
<h2database.version>1.4.197</h2database.version>
|
||||
|
@ -3,9 +3,15 @@ package com.baeldung.flips;
|
||||
import org.flips.describe.config.FlipWebContextConfiguration;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(exclude = {
|
||||
DataSourceAutoConfiguration.class,
|
||||
DataSourceTransactionManagerAutoConfiguration.class,
|
||||
HibernateJpaAutoConfiguration.class })
|
||||
@Import(FlipWebContextConfiguration.class)
|
||||
public class ApplicationConfig {
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.baeldung.jsonp;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.support.SpringBootServletInitializer;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@SpringBootApplication(exclude = {
|
||||
DataSourceAutoConfiguration.class,
|
||||
DataSourceTransactionManagerAutoConfiguration.class,
|
||||
HibernateJpaAutoConfiguration.class })
|
||||
@PropertySource("classpath:jsonp-application.properties")
|
||||
public class JsonPApplication extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(JsonPApplication.class);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SpringApplication.run(JsonPApplication.class, args);
|
||||
}
|
||||
}
|
38
spring-4/src/main/java/com/baeldung/jsonp/model/Company.java
Normal file
38
spring-4/src/main/java/com/baeldung/jsonp/model/Company.java
Normal file
@ -0,0 +1,38 @@
|
||||
package com.baeldung.jsonp.model;
|
||||
|
||||
public class Company {
|
||||
|
||||
private long id;
|
||||
private String name;
|
||||
|
||||
public Company() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Company(final long id, final String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Company [id=" + id + ", name=" + name + "]";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.baeldung.jsonp.web.controller;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.baeldung.jsonp.model.Company;
|
||||
|
||||
@Controller
|
||||
public class CompanyController {
|
||||
|
||||
@RequestMapping(value = "/companyResponseBody", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Company getCompanyResponseBody() {
|
||||
final Company company = new Company(2, "ABC");
|
||||
return company;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/companyResponseEntity", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Company> getCompanyResponseEntity() {
|
||||
final Company company = new Company(3, "123");
|
||||
return new ResponseEntity<Company>(company, HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.baeldung.jsonp.web.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
@Controller
|
||||
public class IndexController {
|
||||
|
||||
@RequestMapping()
|
||||
public String retrieveIndex() {
|
||||
return "index";
|
||||
}
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
package com.baeldung.web.controller.advice;
|
||||
package com.baeldung.jsonp.web.controller.advice;
|
||||
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.AbstractJsonpResponseBodyAdvice;
|
||||
|
||||
// AbstractJsonpResponseBodyAdvice was deprecated in favor of configuring CORS properly
|
||||
// We still want to cover the usage of JSON-P in our articles, therefore we don't care that it was deprecated.
|
||||
@SuppressWarnings("deprecation")
|
||||
@ControllerAdvice
|
||||
public class JsonpControllerAdvice extends AbstractJsonpResponseBodyAdvice {
|
||||
|
@ -2,4 +2,4 @@ feature.foo.by.id=Y
|
||||
feature.new.foo=Y
|
||||
last.active.after=2018-03-14T00:00:00Z
|
||||
first.active.after=2999-03-15T00:00:00Z
|
||||
logging.level.org.flips=info
|
||||
logging.level.org.flips=info
|
||||
|
2
spring-4/src/main/resources/jsonp-application.properties
Normal file
2
spring-4/src/main/resources/jsonp-application.properties
Normal file
@ -0,0 +1,2 @@
|
||||
spring.mvc.view.prefix=/WEB-INF/jsp/
|
||||
spring.mvc.view.suffix=.jsp
|
66
spring-4/src/main/webapp/WEB-INF/jsp/index.jsp
Normal file
66
spring-4/src/main/webapp/WEB-INF/jsp/index.jsp
Normal file
@ -0,0 +1,66 @@
|
||||
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
|
||||
pageEncoding="ISO-8859-1" %>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="ISO-8859-1">
|
||||
<title>Company Data</title>
|
||||
<script src="https://code.jquery.com/jquery-3.1.0.js"
|
||||
integrity="sha256-slogkvB1K3VOkzAI8QITxV3VzpOnkeNVsKvtkYLMjfk="
|
||||
crossorigin="anonymous"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$('#ResponseBody-button').click(function() {
|
||||
$.ajax({
|
||||
url: 'http://localhost:8080/spring-mvc-java/companyResponseBody?callback=getCompanyData',
|
||||
data: {
|
||||
format: 'json'
|
||||
},
|
||||
type: 'GET',
|
||||
jsonpCallback:'getCompanyData',
|
||||
dataType: 'jsonp',
|
||||
error: function() {
|
||||
$('#infoResponseBody').html('<p>An error has occurred</p>');
|
||||
},
|
||||
success: function(data) {
|
||||
console.log("sucess");
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#ResponseEntity-button').click(function() {
|
||||
console.log("ResponseEntity");
|
||||
$.ajax({
|
||||
url: 'http://localhost:8080/spring-mvc-java/companyResponseEntity?callback=getCompanyData',
|
||||
data: {
|
||||
format: 'json'
|
||||
},
|
||||
type: 'GET',
|
||||
jsonpCallback:'getCompanyData',
|
||||
dataType: 'jsonp',
|
||||
error: function() {
|
||||
$('#infoResponseEntity').html('<p>An error has occurred</p>');
|
||||
},
|
||||
success: function(data) {
|
||||
console.log("sucess");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function getCompanyData(data) {
|
||||
$("#response").append("<b>ID:</b> "+data.id+"<br/>");
|
||||
$("#response").append("<b>NAME:</b> "+data.name+"<br/>");
|
||||
$("#response").append("<br/>");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!--Using @ResponseBody -->
|
||||
<button id="ResponseBody-button">Send AJAX JSON-P request!</button>
|
||||
|
||||
<div id="response"></div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -10,9 +10,9 @@
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-spring-5-1</artifactId>
|
||||
<artifactId>parent-spring-5</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-spring-5-1</relativePath>
|
||||
<relativePath>../parent-spring-5</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -11,9 +11,9 @@
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-spring-5-1</artifactId>
|
||||
<artifactId>parent-spring-5</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-spring-5-1</relativePath>
|
||||
<relativePath>../parent-spring-5</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -11,7 +11,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||
- [Introduction to Advice Types in Spring](http://www.baeldung.com/spring-aop-advice-tutorial)
|
||||
- [A Guide to the ViewResolver in Spring MVC](http://www.baeldung.com/spring-mvc-view-resolver-tutorial)
|
||||
- [Integration Testing in Spring](http://www.baeldung.com/integration-testing-in-spring)
|
||||
- [Spring JSON-P with Jackson](http://www.baeldung.com/spring-jackson-jsonp)
|
||||
- [A Quick Guide to Spring MVC Matrix Variables](http://www.baeldung.com/spring-mvc-matrix-variables)
|
||||
- [Intro to WebSockets with Spring](http://www.baeldung.com/websockets-spring)
|
||||
- [File Upload with Spring MVC](http://www.baeldung.com/spring-file-upload)
|
||||
|
@ -8,10 +8,10 @@
|
||||
<packaging>war</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-spring-5-1</artifactId>
|
||||
<artifactId>parent-spring-5</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-spring-5-1</relativePath>
|
||||
<relativePath>../parent-spring-5</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@ -60,6 +60,12 @@
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>${commons-fileupload.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.htmlunit</groupId>
|
||||
@ -70,8 +76,17 @@
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Thymeleaf -->
|
||||
<dependency>
|
||||
@ -255,6 +270,7 @@
|
||||
<guava.version>19.0</guava.version>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<commons-fileupload.version>1.3.2</commons-fileupload.version>
|
||||
<commons-io.version>2.5</commons-io.version>
|
||||
<jsonpath.version>2.2.0</jsonpath.version>
|
||||
|
||||
<!-- testing -->
|
||||
|
@ -60,17 +60,4 @@ public class CompanyController {
|
||||
result.put("name", name);
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/companyResponseBody", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Company getCompanyResponseBody() {
|
||||
final Company company = new Company(2, "ABC");
|
||||
return company;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/companyResponseEntity", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Company> getCompanyResponseEntity() {
|
||||
final Company company = new Company(3, "123");
|
||||
return new ResponseEntity<Company>(company, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,10 @@
|
||||
package com.baeldung.config;
|
||||
|
||||
import com.baeldung.web.controller.handlermapping.BeanNameHandlerMappingController;
|
||||
import com.baeldung.web.controller.handlermapping.SimpleUrlMappingController;
|
||||
import com.baeldung.web.controller.handlermapping.WelcomeController;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping;
|
||||
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.baeldung.web.controller.handlermapping.BeanNameHandlerMappingController;
|
||||
import com.baeldung.web.controller.handlermapping.WelcomeController;
|
||||
|
||||
|
||||
@Configuration
|
||||
|
@ -9,7 +9,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.ViewResolver;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
import org.thymeleaf.spring4.SpringTemplateEngine;
|
||||
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
|
||||
import org.thymeleaf.templateresolver.ServletContextTemplateResolver;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.baeldung.web.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
@ -20,7 +20,6 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import com.baeldung.spring.web.config.WebConfig;
|
||||
import com.baeldung.spring.web.config.WebConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
|
Loading…
x
Reference in New Issue
Block a user