У меня утечка памяти при использовании этого специального метода, который возвращает CGImageRef. Я не могу правильно выпустить "cgImage", потому что мне нужно его вернуть. 31 декабря 2010 г., 20:15 Очень грязное исправление, но именно так я временно заставил работать messageSource. Я изменил свой класс контроллера, чтобы передать 'messageSource' классу Message, и я ...
Новые обновления:
31 декабря 2010 г., 20:15
Очень грязное исправление, но именно так я временно заставил работать messageSource. Я изменил свой класс контроллера, чтобы передать «messageSource» классу сообщений, и теперь я могу получать сообщения. Пожалуйста, просмотрите определение класса ниже и дайте мне знать больше информации, которая может вам понадобиться. Я очень ценю вашу помощь.
31 декабря 2010 г., 15:00
Поскольку мне не удалось настроить messageSource с помощью аннотаций, я попытался настроить внедрение messageSource через servlet-context.xml. У меня все еще есть messageSource как null. Пожалуйста, дайте мне знать, если вам нужна более конкретная информация, и я предоставлю. Заранее благодарны за Вашу помощь.
servlet-context.xml
<beans:bean id="message"
class="com.mycompany.myapp.domain.common.message.Message">
<beans:property name="messageSource" ref="messageSource" />
</beans:bean>
Spring дает следующее информационное сообщение об инициализации Spring.
INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Overriding bean definition for bean 'message': replacing [Generic bean: class [com.mycompany.myapp.domain.common.message.Message]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [C:\springsource\tc-server-developer-2.1.0.RELEASE\spring-insight-instance\wtpwebapps\myapp\WEB-INF\classes\com\mycompany\myapp\domain\common\message\Message.class]] with [Generic bean: class [com.mycompany.myapp.domain.common.message.Message]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]]
INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1c7caac5: defining beans [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,xxxDao,message,xxxService,jsonDateSerializer,xxxController,homeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,tilesViewResolver,tilesConfigurer,messageSource,org.springframework.web.servlet.handler.MappedInterceptor#1,localeResolver,org.springframework.web.servlet.view.ContentNegotiatingViewResolver#0,validator,resourceBundleLocator,messageInterpolator]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@4f47af3
У меня есть приведенное ниже определение источника сообщения в 3-х классах. В режиме отладки я вижу, что в классе xxxController
, messageSource
инициализируется как org.springframework.context.support.ReloadableResourceBundleMessageSource
. Я аннотировал класс сообщений с помощью @Component и xxxHibernateDaoImpl с помощью @Repository. Я также включил определение пространства имен контекста в servlet-context.xml. Но в классе Message
и xxxHibernateDaoImpl
, messageSource
по-прежнему имеет значение null.
Почему Spring не инициализирует messageSource в двух других классах, хотя в xxxController
, он правильно инициализируется?
@Controller
public class xxxController{
@Autowired
private ReloadableResourceBundleMessageSource messageSource;
}
@Component
public class Message{
@Autowired
private ReloadableResourceBundleMessageSource messageSource;
}
@Repository("xxxDao")
public class xxxHibernateDaoImpl{
@Autowired
private ReloadableResourceBundleMessageSource messageSource;
}
<beans:beans
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<beans:bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<beans:property name="basename" value="/resources/messages/messages" />
</beans:bean>
<context:component-scan base-package="com.mycompany.myapp"/>
</beans>