Spring-dispatcher-servlet.xml to Java Config
<p>Hi i'm trying to convert my Xml configuration to Java Config. I'm really lost now.</p>

<p>Here is the <strong>spring-dispatcher-servlet.xml</strong></p>

<pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc.xsd"&gt;

    &lt;!-- package of spring controller --&gt;
    &lt;context:component-scan base-package="com.test" /&gt;
    &lt;mvc:annotation-driven /&gt;

    &lt;bean
        class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt;
        &lt;property name="cacheSeconds" value="0" /&gt;
    &lt;/bean&gt;

    &lt;mvc:resources mapping="/Resources/**" location="/Resources/"
        cache-period="31556926" /&gt;

    &lt;bean id="viewResolver1" class="org.springframework.web.servlet.view.XmlViewResolver"&gt;
        &lt;property name="location" value="/WEB-INF/excel-view.xml" /&gt;
    &lt;/bean&gt;

    &lt;bean id="viewResolver2"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
        &lt;property name="prefix"&gt;
            &lt;value&gt;/WEB-INF/jsp/&lt;/value&gt;
        &lt;/property&gt;
        &lt;property name="suffix"&gt;
            &lt;value&gt;.jsp&lt;/value&gt;
        &lt;/property&gt;
    &lt;/bean&gt;

    &lt;bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
        &lt;!-- setting maximum upload size --&gt;
        &lt;property name="maxUploadSize" value="100000" /&gt;
    &lt;/bean&gt;

    &lt;!-- Read test.properties --&gt;
    &lt;bean
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
        &lt;property name="location"&gt;
            &lt;value&gt;classpath:test.properties&lt;/value&gt;
        &lt;/property&gt;
    &lt;/bean&gt;

    &lt;bean id="entityManagerFactoryBean"
        class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
        &lt;property name="dataSource" ref="dataSource" /&gt;
        &lt;!-- This makes /META-INF/persistence.xml is no longer necessary --&gt;
        &lt;property name="packagesToScan" value="com.beo.model" /&gt;
        &lt;!-- JpaVendorAdapter implementation for Hibernate EntityManager. Exposes 
            Hibernate's persistence provider and EntityManager extension interface --&gt;
        &lt;property name="jpaVendorAdapter"&gt;
            &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" /&gt;
        &lt;/property&gt;
        &lt;property name="jpaProperties"&gt;
            &lt;props&gt;
                &lt;!-- &lt;prop key="hibernate.hbm2ddl.auto"&gt;create&lt;/prop&gt; --&gt;
                &lt;!-- &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt; --&gt;
                &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.PostgreSQLDialect&lt;/prop&gt;
            &lt;/props&gt;
        &lt;/property&gt;
    &lt;/bean&gt;

    &lt;bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource"&gt;
        &lt;!-- Hikari Config --&gt;
        &lt;property name="dataSourceClassName" value="${hikari.dataSourceClassName}" /&gt;
        &lt;property name="maximumPoolSize" value="${hikari.maximumPoolSize}" /&gt;
        &lt;property name="maxLifetime" value="${hikari.maxLifetime}" /&gt;
        &lt;property name="idleTimeout" value="${hikari.idleTimeout}" /&gt;

        &lt;property name="dataSourceProperties"&gt;
            &lt;props&gt;
                &lt;prop key="url"&gt;${jdbc.url}&lt;/prop&gt;
                &lt;prop key="user"&gt;${jdbc.username}&lt;/prop&gt;
                &lt;prop key="password"&gt;${jdbc.password}&lt;/prop&gt;
            &lt;/props&gt;
        &lt;/property&gt;
    &lt;/bean&gt;


    &lt;!-- This transaction manager is appropriate for applications that use a 
        single JPA EntityManagerFactory for transactional data access. JTA (usually 
        through JtaTransactionManager) is necessary for accessing multiple transactional 
        resources within the same transaction. --&gt;
    &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
        &lt;property name="entityManagerFactory" ref="entityManagerFactoryBean" /&gt;
    &lt;/bean&gt;

    &lt;!-- responsible for registering the necessary Spring components that power 
        annotation-driven transaction management; such as when @Transactional methods 
        are invoked --&gt;
    &lt;tx:annotation-driven /&gt;
&lt;/beans&gt;
</code></pre>

<p>Here is what i came up for the <strong>Java Config</strong>.</p>

<pre><code>@Configuration
@EnableWebMvc
@ComponentScan("com.test")
public class WebConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(final ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/Resources/**")
                .addResourceLocations("/Resources/").setCachePeriod(31556926);
    }

    @Override
    public void configureDefaultServletHandling(
            DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }

    @Bean
    public ViewResolver setupViewResolver(ContentNegotiationManager manager) {
        List&lt;ViewResolver&gt; resolvers = new ArrayList&lt;ViewResolver&gt;();


        InternalResourceViewResolver InternalResourceResolver = new InternalResourceViewResolver();
        InternalResourceResolver.setPrefix("/WEB-INF/jsp/");
        InternalResourceResolver.setSuffix(".jsp");
        resolvers.add(InternalResourceResolver);

        ContentNegotiatingViewResolver resolver2 = new ContentNegotiatingViewResolver();
        resolver2.setViewResolvers(resolvers);
        resolver2.setContentNegotiationManager(manager);
        return resolver2;

    }
}
</code></pre>

<p>Thank you so much in advance for the help.</p>