Java Spring MVC项目突然变得非常缓慢

时间:2015-02-07 10:04:06

标签: java spring performance spring-mvc

我的春季项目突然变得非常缓慢,无论是在启动时还是提供某种要求。 我没有在web.xml \ spring-context中改变任何东西,但这一切都变得很慢。

启动从大约5秒到30秒,登录服务需要大约15秒,而在控制台弹簧似乎什么也没做。

为了更清楚,这是启动弹簧日志:

http://pastebin.com/DezpJRJb

在启动过程中,内部bean实例化似乎非常慢。

07/02/2015 10:58:02 - DEBUG - (AbstractBeanFactory.java:247) - Returning cached instance of singleton bean 'lastFmController'

在spring-context.xml中,我在寻找控制器时声明要首先扫描包:

<context:component-scan base-package="org.fabrizio.lastfmmusicrecommender.controller" />

直到昨天这一切都很有效,似乎没有理由出现问题。

我还发布了web.xml \ spring-context.xml \ springmvc-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>LastFmCarMusicRecommender</display-name>
    <welcome-file-list>
        <welcome-file>/index.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/spring-context.xml</param-value>
</init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>springmvc</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-4.0.xsd">

 <context:component-scan base-package="org.fabrizio.lastfmmusicrecommender.controller" />

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/views/" />
        <property name="suffix" value=".jsp" />
    </bean>


</beans>

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        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">

    <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

    <!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven />

    <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
    <resources mapping="/resources/**" location="/resources/" />

    <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
    <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean>

    <context:component-scan base-package="org.fabrizio.lastfmmusicrecommender.controller" />
        <mvc:resources mapping="/css/**" location="/css/" />

    <context:component-scan base-package="org.fabrizio.lastfmmusicrecommender.controller" />
        <mvc:resources mapping="/images/**" location="/images/" />

    <context:component-scan base-package="org.fabrizio.lastfmmusicrecommender.controller" />
        <mvc:resources mapping="/js/**" location="/js/" />
        <context:component-scan base-package="org.fabrizio.lastfmmusicrecommender.controller" />
        <mvc:resources mapping="/fonts/**" location="/fonts/" />

</beans:beans>

0 个答案:

没有答案