我问了一个类似的问题,以为得到了回答。然而,昨天它停止工作,所以我要再问一遍,但我的修改类。我希望这是正确的协议....
我有一个spring启动网站,它在启动时抛出一个空指针,因为其中一个类没有自动连线。以下是我的设置:
package com.company.product
@Configuration
@ComponentScan
@EnableJpaRepositories
@EnableAutoConfiguration
public class OFAC {
public static void main(String[] args) {
ApplicationContext ofac = SpringApplication.run( OFAC.class, args );
}
}
在子包中,我有:package com.company.product.configuration@configuration@componentScan()public class OFAConfiguration{
@Autowired
private ConfigurationSettings configurationSettings;
@Bean
public EmbeddedServletContainerFactory servletContainer() {
int port = 9000;
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
if ( configurationSettings.getServerPort()!= null ) {
port = Integer.parseInt( configurationSettings.getServerPort());
}
factory.setPort( port );
factory.setSessionTimeout( 30, TimeUnit.MINUTES );
factory.addErrorPages( new ErrorPage( HttpStatus.NOT_FOUND, "/notfound.html" ) );
return factory;
}
..}
当@AutoWired时,下面的类为空,但我可以设置断点并看到它被初始化。包com.company.product.configuration@component@configurationproperties()公共类
@Value("${ofac.appName}")
private String appName;
@Value("${ofac.appDescription}")
private String appDescription;
@Value("${ofac.serverPort}")
private String serverPort;
// getters and setters
..
}
这是因为ConfigurationSettings为null而引发空指针的地方:package com.company.product.service@Component public class FileDownloadService{
@Autowired
private ConfigurationSettings configurationSettings;
private List<String> paths = new ArrayList<String>();
public FileDownloadService() {
paths.add( configurationSettings.getFileDownloadSdn() );
paths.add( configurationSettings.getFileDownloadAdd() );
paths.add( configurationSettings.getFilDownloadAlt() );
paths.add( configurationSettings.getFileDownloadXmlHeader() );
}
下面是我的日志输出:
:: Spring Boot :: (v1.0.0.RC4)
2014-03-14 17:59:16.975 INFO 41410 --- [ main] com.company.product.OFAC : Starting OFAC on Edelweiss.local with PID 41410 (/Users/David/projects/cnet/OFAC/out/production/OFAC started by...)
2014-03-14 17:59:16.981 DEBUG 41410 --- [ main] o.s.boot.SpringApplication : Loading source class com.company.product.OFAC
2014-03-14 17:59:17.517 INFO 41410 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@64de5c64: startup date [Fri Mar 14 17:59:17 MDT 2014]; root of context hierarchy
2014-03-14 17:59:17.522 DEBUG 41410 --- [ main] ationConfigEmbeddedWebApplicationContext : Bean factory for org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@64de5c64: org.springframework.beans.factory.support.DefaultListableBeanFactory@600f2cb8: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,OFAC]; root of factory hierarchy
2014-03-14 17:59:20.249 DEBUG 41410 --- [ main] ationConfigEmbeddedWebApplicationContext : Using MessageSource [org.springframework.context.support.ReloadableResourceBundleMessageSource: basenames=[classpath:messages/messages,classpath:messages/validation]]
2014-03-14 17:59:20.249 DEBUG 41410 --- [ main] ationConfigEmbeddedWebApplicationContext : Using ApplicationEventMulticaster [org.springframework.context.event.SimpleApplicationEventMulticaster@4e5197fd]
2014-03-14 17:59:25.590 DEBUG 41410 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Code archive: /..gvm/gradle/1.10/bin/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/1.0.0.RC4/b8934d1dcdfd6f454ad86ea7372fd8a6dd2f6e61/spring-boot-1.0.0.RC4.jar
2014-03-14 17:59:25.591 DEBUG 41410 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Code archive: /..gvm/gradle/1.10/bin/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/1.0.0.RC4/b8934d1dcdfd6f454ad86ea7372fd8a6dd2f6e61/spring-boot-1.0.0.RC4.jar
2014-03-14 17:59:25.591 DEBUG 41410 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Document root: /Users/me/projects/cnet/OFAC/src/main/webapp
2014-03-14 17:59:25.642 INFO 41410 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 9001
2014-03-14 17:59:26.156 INFO 41410 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2014-03-14 17:59:26.157 INFO 41410 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.52
2014-03-14 17:59:26.463 INFO 41410 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2014-03-14 17:59:26.464 INFO 41410 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 8954 ms
2014-03-14 17:59:27.348 INFO 41410 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2014-03-14 17:59:27.353 INFO 41410 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2014-03-14 17:59:28.064 INFO 41410 --- [ost-startStop-1] o.a.catalina.util.SessionIdGenerator : Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [203] milliseconds.
2014-03-14 17:59:28.232 INFO 41410 --- [ main] o.s.j.d.e.EmbeddedDatabaseFactory : Creating embedded database 'ofac'
2014-03-14 17:59:28.509 INFO 41410 --- [ main] o.s.j.d.init.ResourceDatabasePopulator : Executing SQL script from class path resource [h2.sql]
2014-03-14 17:59:28.526 INFO 41410 --- [ main] o.s.j.d.init.ResourceDatabasePopulator : Done executing SQL script from class path resource [h2.sql] in 17 ms.
2014-03-14 17:59:28.763 INFO 41410 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2014-03-14 17:59:28.814 INFO 41410 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2014-03-14 17:59:29.117 INFO 41410 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {4.3.1.Final}
2014-03-14 17:59:29.120 INFO 41410 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2014-03-14 17:59:29.123 INFO 41410 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2014-03-14 17:59:29.545 INFO 41410 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
2014-03-14 17:59:29.684 INFO 41410 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2014-03-14 17:59:29.846 INFO 41410 --- [ main] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory
2014-03-14 17:59:30.010 INFO 41410 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000228: Running hbm2ddl schema update
2014-03-14 17:59:30.011 INFO 41410 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000102: Fetching database metadata
2014-03-14 17:59:30.014 INFO 41410 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000396: Updating schema
2014-03-14 17:59:30.015 INFO 41410 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000232: Schema update complete
2014-03-14 17:59:39.493 INFO 41410 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2014-03-14 17:59:39.558 INFO 41410 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
=========================
AUTO-CONFIGURATION REPORT
=========================
Positive matches:
-----------------
PropertyPlaceholderAutoConfiguration#propertySourcesPlaceholderConfigurer
- @ConditionalOnMissingBean (types: org.springframework.context.support.PropertySourcesPlaceholderConfigurer; SearchStrategy: current) found no beans (OnBeanCondition)
AopAutoConfiguration
- @ConditionalOnClass classes found: org.springframework.context.annotation.EnableAspectJAutoProxy,org.aspectj.lang.annotation.Aspect,org.aspectj.lang.reflect.Advice (OnClassCondition)
- SpEL expression on org.springframework.boot.autoconfigure.aop.AopAutoConfiguration: ${spring.aop.auto:true} (OnExpressionCondition)
AopAutoConfiguration.JdkDynamicAutoProxyConfiguration
- SpEL expression on org.springframework.boot.autoconfigure.aop.AopAutoConfiguration$JdkDynamicAutoProxyConfiguration: !${spring.aop.proxyTargetClass:false} (OnExpressionCondition)
JpaRepositoriesAutoConfiguration
- @ConditionalOnClass classes found: org.springframework.data.jpa.repository.JpaRepository (OnClassCondition)
- @ConditionalOnBean (types: javax.sql.DataSource; SearchStrategy: all) found the following [dataSource] @ConditionalOnMissingBean (types: org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean; SearchStrategy: all) found no beans (OnBeanCondition)
JpaRepositoriesAutoConfiguration.JpaWebConfiguration
- found web application StandardServletEnvironment (OnWebApplicationCondition)
- @ConditionalOnMissingBean (types: org.springframework.data.web.PageableHandlerMethodArgumentResolver; SearchStrategy: all) found no beans (OnBeanCondition)
DataSourceAutoConfiguration
- @ConditionalOnClass classes found: org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType (OnClassCondition)
DataSourceAutoConfiguration.JdbcTemplateConfiguration
- existing auto database detected (DataSourceAutoConfiguration.DatabaseCondition)
DataSourceAutoConfiguration.JdbcTemplateConfiguration#jdbcTemplate
- @ConditionalOnMissingBean (types: org.springframework.jdbc.core.JdbcOperations; SearchStrategy: all) found no beans (OnBeanCondition)
DataSourceAutoConfiguration.JdbcTemplateConfiguration#namedParameterJdbcTemplate
- @ConditionalOnMissingBean (types: org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations; SearchStrategy: all) found no beans (OnBeanCondition)
DataSourceTransactionManagerAutoConfiguration
- @ConditionalOnClass classes found: org.springframework.jdbc.core.JdbcTemplate,org.springframework.transaction.PlatformTransactionManager (OnClassCondition)
JmxAutoConfiguration
- @ConditionalOnClass classes found: org.springframework.jmx.export.MBeanExporter (OnClassCondition)
- SpEL expression on org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration: ${spring.jmx.enabled:true} (OnExpressionCondition)
- @ConditionalOnMissingBean (types: org.springframework.jmx.export.MBeanExporter; SearchStrategy: all) found no beans (OnBeanCondition)
HibernateJpaAutoConfiguration
- found HibernateEntityManager class (HibernateJpaAutoConfiguration.HibernateEntityManagerCondition)
- @ConditionalOnClass classes found: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean,org.springframework.transaction.annotation.EnableTransactionManagement,javax.persistence.EntityManager (OnClassCondition)
JpaBaseConfiguration.JpaWebConfiguration
- found web application StandardServletEnvironment (OnWebApplicationCondition)
- SpEL expression on org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration$JpaWebConfiguration: ${spring.jpa.openInView:${spring.jpa.open_in_view:true}} (OnExpressionCondition)
- @ConditionalOnMissingBean (types: org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor,org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter; SearchStrategy: all) found no beans (OnBeanCondition)
ThymeleafAutoConfiguration
- @ConditionalOnClass classes found: org.thymeleaf.spring4.SpringTemplateEngine (OnClassCondition)
ThymeleafAutoConfiguration.DefaultTemplateResolverConfiguration
- @ConditionalOnMissingBean (names: defaultTemplateResolver; SearchStrategy: all) found no beans (OnBeanCondition)
ThymeleafAutoConfiguration.ThymeleafDefaultConfiguration
- @ConditionalOnMissingBean (types: org.thymeleaf.spring4.SpringTemplateEngine; SearchStrategy: all) found no beans (OnBeanCondition)
ThymeleafAutoConfiguration.ThymeleafViewResolverConfiguration
- @ConditionalOnClass classes found: javax.servlet.Servlet (OnClassCondition)
com.edelweissco.ofac
ThymeleafAutoConfiguration.ThymeleafViewResolverConfiguration#thymeleafViewResolver
- @ConditionalOnMissingBean (names: thymeleafViewResolver; SearchStrategy: all) found no beans (OnBeanCondition)
DispatcherServletAutoConfiguration
- found web application StandardServletEnvironment (OnWebApplicationCondition)
- @ConditionalOnClass classes found: org.springframework.web.servlet.DispatcherServlet (OnClassCondition)
DispatcherServletAutoConfiguration.DispatcherServletConfiguration
- no DispatcherServlet found (DispatcherServletAutoConfiguration.DefaultDispatcherServletCondition)
- @ConditionalOnClass classes found: javax.servlet.ServletRegistration (OnClassCondition)
EmbeddedServletContainerAutoConfiguration
- found web application StandardServletEnvironment (OnWebApplicationCondition)
HttpMessageConvertersAutoConfiguration
- @ConditionalOnClass classes found: org.springframework.http.converter.HttpMessageConverter (OnClassCondition)
HttpMessageConvertersAutoConfiguration#messageConverters
- @ConditionalOnMissingBean (types: org.springframework.boot.autoconfigure.web.HttpMessageConverters; SearchStrategy: all) found no beans (OnBeanCondition)
HttpMessageConvertersAutoConfiguration.ObjectMappers
- @ConditionalOnClass classes found: com.fasterxml.jackson.databind.ObjectMapper (OnClassCondition)
HttpMessageConvertersAutoConfiguration.ObjectMappers#jacksonObjectMapper
- @ConditionalOnMissingBean (types: com.fasterxml.jackson.databind.ObjectMapper; SearchStrategy: all) found no beans (OnBeanCondition)
HttpMessageConvertersAutoConfiguration.ObjectMappers#mappingJackson2HttpMessageConverter
- @ConditionalOnMissingBean (types: org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; SearchStrategy: all) found no beans (OnBeanCondition)
ServerPropertiesAutoConfiguration
- found web application StandardServletEnvironment (OnWebApplicationCondition)
ServerPropertiesAutoConfiguration#serverProperties
- @ConditionalOnMissingBean (types: org.springframework.boot.autoconfigure.web.ServerProperties; SearchStrategy: current) found no beans (OnBeanCondition)
WebMvcAutoConfiguration
- found web application StandardServletEnvironment (OnWebApplicationCondition)
- @ConditionalOnClass classes found: javax.servlet.Servlet,org.springframework.web.servlet.DispatcherServlet,org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter (OnClassCondition)
- @ConditionalOnMissingBean (types: org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; SearchStrategy: all) found no beans (OnBeanCondition)
WebMvcAutoConfiguration#hiddenHttpMethodFilter
- @ConditionalOnMissingBean (types: org.springframework.web.filter.HiddenHttpMethodFilter; SearchStrategy: all) found no beans (OnBeanCondition)
WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#defaultViewResolver
- @ConditionalOnMissingBean (types: org.springframework.web.servlet.view.InternalResourceViewResolver; SearchStrategy: all) found no beans (OnBeanCondition)
WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#requestContextListener
- @ConditionalOnMissingBean (types: org.springframework.web.context.request.RequestContextListener; SearchStrategy: all) found no beans (OnBeanCondition)
Negative matches:
-----------------
MessageSourceAutoConfiguration
- @ConditionalOnMissingBean (types: org.springframework.context.MessageSource; SearchStrategy: all) found the following [messageSource] (OnBeanCondition)
RabbitAutoConfiguration
- required @ConditionalOnClass classes not found: org.springframework.amqp.rabbit.core.RabbitTemplate,com.rabbitmq.client.Channel (OnClassCondition)
AopAutoConfiguration.CglibAutoProxyConfiguration
- SpEL expression on org.springframework.boot.autoconfigure.aop.AopAutoConfiguration$CglibAutoProxyConfiguration: ${spring.aop.proxyTargetClass:false} (OnExpressionCondition)
BatchAutoConfiguration
- required @ConditionalOnClass classes not found: org.springframework.batch.core.launch.JobLauncher (OnClassCondition)
MongoRepositoriesAutoConfiguration
- required @ConditionalOnClass classes not found: com.mongodb.Mongo,org.springframework.data.mongodb.repository.MongoRepository (OnClassCondition)
MongoTemplateAutoConfiguration
- required @ConditionalOnClass classes not found: com.mongodb.Mongo,org.springframework.data.mongodb.core.MongoTemplate (OnClassCondition)
DataSourceAutoConfiguration.DbcpConfiguration
- Tomcat DataSource (DataSourceAutoConfiguration.BasicDatabaseCondition)
DataSourceAutoConfiguration.EmbeddedConfiguration
- existing non-embedded database detected (DataSourceAutoConfiguration.EmbeddedDatabaseCondition)
DataSourceAutoConfiguration.TomcatConfiguration
- found database driver org.h2.Driver (DataSourceAutoConfiguration.TomcatDatabaseCondition)
- @ConditionalOnMissingBean (types: javax.sql.DataSource; SearchStrategy: all) found the following [dataSource] (OnBeanCondition)
DataSourceTransactionManagerAutoConfiguration#transactionManager
- @ConditionalOnMissingBean (names: transactionManager; SearchStrategy: all) found the following [transactionManager] (OnBeanCondition)
DataSourceTransactionManagerAutoConfiguration.TransactionManagementConfiguration
- required @ConditionalOnMissing classes found: org.springframework.transaction.annotation.AbstractTransactionManagementConfiguration (OnClassCondition)
JmsTemplateAutoConfiguration
- required @ConditionalOnClass classes not found: org.springframework.jms.core.JmsTemplate,javax.jms.ConnectionFactory (OnClassCondition)
DeviceResolverAutoConfiguration
- required @ConditionalOnClass classes not found: org.springframework.mobile.device.DeviceResolverHandlerInterceptor,org.springframework.mobile.device.DeviceHandlerMethodArgumentResolver (OnClassCondition)
MongoAutoConfiguration
- required @ConditionalOnClass classes not found: com.mongodb.Mongo (OnClassCondition)
JpaBaseConfiguration#entityManagerFactory
- @ConditionalOnMissingBean (names: entityManagerFactory; SearchStrategy: all) found the following [entityManagerFactory] (OnBeanCondition)
JpaBaseConfiguration#jpaVendorAdapter
- @ConditionalOnMissingBean (types: org.springframework.orm.jpa.JpaVendorAdapter; SearchStrategy: all) found the following [jpaVendorAdapter] (OnBeanCondition)
JpaBaseConfiguration#transactionManager
- @ConditionalOnMissingBean (types: org.springframework.transaction.PlatformTransactionManager; SearchStrategy: all) found the following [transactionManager] (OnBeanCondition)
ReactorAutoConfiguration
- required @ConditionalOnClass classes not found: reactor.spring.context.config.EnableReactor (OnClassCondition)
RedisAutoConfiguration
- required @ConditionalOnClass classes not found: org.springframework.data.redis.connection.lettuce.LettuceConnection,org.springframework.data.redis.core.RedisOperations,com.lambdaworks.redis.RedisClient (OnClassCondition)
SecurityAutoConfiguration
- required @ConditionalOnClass classes not found: org.springframework.security.authentication.AuthenticationManager (OnClassCondition)
ThymeleafAutoConfiguration.ThymeleafSecurityDialectConfiguration
- required @ConditionalOnClass classes not found: org.thymeleaf.extras.springsecurity3.dialect.SpringSecurityDialect (OnClassCondition)
ThymeleafAutoConfiguration.ThymeleafWebLayoutConfiguration
- required @ConditionalOnClass classes not found: nz.net.ultraq.thymeleaf.LayoutDialect (OnClassCondition)
EmbeddedServletContainerAutoConfiguration.EmbeddedJetty
- required @ConditionalOnClass classes not found: org.eclipse.jetty.server.Server,org.eclipse.jetty.util.Loader (OnClassCondition)
EmbeddedServletContainerAutoConfiguration.EmbeddedTomcat
- @ConditionalOnClass classes found: javax.servlet.Servlet,org.apache.catalina.startup.Tomcat (OnClassCondition)
- @ConditionalOnMissingBean (types: org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; SearchStrategy: current) found the following [servletContainer] (OnBeanCondition)
MultipartAutoConfiguration
- @ConditionalOnClass classes found: javax.servlet.Servlet,org.springframework.web.multipart.support.StandardServletMultipartResolver (OnClassCondition)
- @ConditionalOnBean (types: javax.servlet.MultipartConfigElement; SearchStrategy: all) found no beans (OnBeanCondition)
WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#beanNameViewResolver
- @ConditionalOnBean (types: org.springframework.web.servlet.View; SearchStrategy: all) found no beans (OnBeanCondition)
WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#viewResolver
- @ConditionalOnBean (types: org.springframework.web.servlet.View; SearchStrategy: all) found no beans (OnBeanCondition)
WebSocketAutoConfiguration
- required @ConditionalOnClass classes not found: org.springframework.web.socket.WebSocketHandler (OnClassCondition)
这里是堆栈跟踪,只是一个标准的NullPointerException。在此调用之前已实例化ConfigurationSetting(根据调试器)。但创建FileDownloadService时,ConfigurationSetting为空。
原因:org.springframework.beans.factory.BeanCreationException:创建文件[.cnet/ofac/out/production/ofac/com/company/product/service/filedownloadservice.class]中定义的名为“file downloadservice”的bean时出错:实例化bean失败;嵌套异常为org.springframework.beans.BeanInstantiationException:无法实例化bean类[com.company.product.service.filedownloadservice]:构造函数引发异常;嵌套异常为java.lang.NullPointerException(位于org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.instantiateBean(位于org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.java:1076)。ActBeanFactory.GetBean(AbstractBeanFactory.java:195)位于org.springframework.beans.factory.support.defaultListableBeanFactory.findAutoRecandates(DefaultListableBeanFactory.java:1014)位于org.springframework.beans.factory.support.defaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:957)位于嵌套异常为org.springframework.beans.beanutils.InstantiateClass(Beanutils.java:164)在org.springframework.beans.factor.support.simpleInstantiationStrategy.Instantiate(SimpleInstantiationStrategy.java:89)在org.springframework.beans.factor.support.abstractautoWirecapablebeanfactor.java:1069)...29更多由以下原因引起的:
现在我发誓,在上周的一些非常好的StackOverflow帮助之后,这一切都起作用了。但是,我现在无法运行我的应用程序,因为启动时的空指针。
很抱歉,我们应该早点看到这一点,但堆栈跟踪表明这一点很明显:这不是spring自动生成错误,因为spring从来没有看到FileDownLoadService
的实例--您在其构造函数中使用了未初始化的字段。如果要引用初始值设定项中的@autowired
字段,请使用@postconstruct
而不是构造函数。
当我开始学习spring-webflux时,我有一个关于这个组件的问题。 我构建了一个简单的项目,使用maven管理该项目,并添加了关于spring-boot-starter-web和spring-boot-starter-webflux的依赖关系“,例如:
我正在努力学习spring boot,我注意到有两种选择。 > spring-boot-starter-web-根据文档,它支持全栈web开发,包括Tomcat和web-mvc spring-Boot-Starter-Tomcat 既然#1支持Tomcat,为什么要使用#2呢? 有什么不同? 谢谢
我在GWT+Spring Boot中创建了一个应用程序,当我尝试使用-时,我得到。显然不起作用,没有将bean插入正确的位置。我怎样才能解决这种情况? 分派传入RPC调用时发生异常 ExpectiontedException:服务方法“public abstract java.util.list com.mygwt.springbootapp.client.userservice.list()”引
主要内容:Spring Boot Web 快速开发,示例 Spring MVC 是 Spring 提供的一个基于 MVC 设计模式的轻量级 Web 开发框架,其本身就是 Spring 框架的一部分,可以与 Spring 无缝集成,性能方面具有先天的优越性,是当今业界最主流的 Web 开发框架之一。 Spring Boot 是在 Spring 的基础上创建一款开源框架,它提供了 spring-boot-starter-web(Web 场景启动器) 来为
batch-web-spring-boot-starter 是由Spring Boot提供支持的企业级生产就绪批处理应用程序。 功能包括: 启动Web应用程序并自动为其部署批处理作业(JavaConfig,XML或JSR-352)。 日志文件分离,每个作业执行一个日志文件。 用于启动和停止作业的操作http端点,用于检索BatchStatus和日志文件。 监视http端点,用于检索有关作业执行的详
我一定错过了一些简单的东西,但是我很难将Autowired属性分配给bean。这里贴出的所有类似答案似乎都围绕着三种解决方案之一: null 我试图制作一个最简的bean来表示我的DAO并将其注入到Web服务中。 DAO接口: DAO实现: 我错过了什么?