[BAEL-15393] - Update Spring File Upload article

This commit is contained in:
amit2103 2019-09-06 01:31:18 +05:30
parent d4bd1335c7
commit 78ca924a13
6 changed files with 17 additions and 64 deletions

View File

@ -19,14 +19,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
@ -40,7 +32,11 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!-- Jackson -->
<dependency>
@ -62,17 +58,6 @@
</dependency>
<!-- common -->
<dependency>
<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>
<artifactId>htmlunit</artifactId>
@ -143,12 +128,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.springframework</groupId> -->
<!-- <artifactId>spring-messaging</artifactId> -->
<!-- <version>${spring.version}</version> -->
<!-- </dependency> -->
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>

View File

@ -23,15 +23,15 @@ public class LoggingAspect {
}
};
@Pointcut("@target(org.springframework.stereotype.Repository)")
@Pointcut("within(com.baeldung..*) && execution(* com.baeldung.dao.FooDao.*(..))")
public void repositoryMethods() {
}
@Pointcut("@annotation(com.baeldung.aop.annotations.Loggable)")
@Pointcut("within(com.baeldung..*) && @annotation(com.baeldung.aop.annotations.Loggable)")
public void loggableMethods() {
}
@Pointcut("@args(com.baeldung.aop.annotations.Entity)")
@Pointcut("within(com.baeldung..*) && @args(com.baeldung.aop.annotations.Entity)")
public void methodsAcceptingEntities() {
}

View File

@ -15,7 +15,7 @@ public class PerformanceAspect {
private static Logger logger = Logger.getLogger(PerformanceAspect.class.getName());
@Pointcut("within(@org.springframework.stereotype.Repository *)")
@Pointcut("within(com.baeldung..*) && execution(* com.baeldung.dao.FooDao.*(..))")
public void repositoryClassMethods() {
}

View File

@ -20,11 +20,11 @@ public class PublishingAspect {
this.eventPublisher = eventPublisher;
}
@Pointcut("@target(org.springframework.stereotype.Repository)")
@Pointcut("within(com.baeldung..*) && execution(* com.baeldung.dao.FooDao.*(..))")
public void repositoryMethods() {
}
@Pointcut("execution(* *..create*(Long,..))")
@Pointcut("within(com.baeldung..*) && execution(* com.baeldung.dao.FooDao.create*(Long,..))")
public void firstLongParamMethods() {
}

View File

@ -12,7 +12,6 @@ import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.http.MediaType;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
@ -63,7 +62,7 @@ public class WebConfig implements WebMvcConfigurer {
final SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setPrefix("/WEB-INF/templates/");
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode("HTML5");
templateResolver.setTemplateMode("HTML");
return templateResolver;
}
@ -87,15 +86,6 @@ public class WebConfig implements WebMvcConfigurer {
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
@Bean(name = "multipartResolver")
public CommonsMultipartResolver multipartResolver() {
final CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
multipartResolver.setMaxUploadSize(100000);
return multipartResolver;
}
@Override
public void extendMessageConverters(final List<HttpMessageConverter<?>> converters) {

View File

@ -1,21 +1,5 @@
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB
spring.http.multipart.enabled=true
spring.servlet.multipart.location=${java.io.tmpdir}
logging.level.org.springframework=DEBUG
logging.level.com.baeldung=DEBUG
#output to a temp_folder/file
logging.file=${java.io.tmpdir}/application.log
# Logging pattern for the console
logging.pattern.console= %d{yyyy-MM-dd HH:mm:ss} - %msg%n
# Logging pattern for file
logging.pattern.file= %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%
spring.http.encoding.charset=UTF-8
# Enable http encoding support.
spring.http.encoding.enabled=true
# Force the encoding to the configured charset on HTTP requests and responses.
spring.http.encoding.force=true
server.servlet.context-path=/spring-mvc-java
spring.servlet.multipart.max-file-size=1MB
spring.servlet.multipart.max-request-size=1MB
spring.servlet.multipart.enabled=true
spring.servlet.multipart.location=${java.io.tmpdir}