Spring 3.0M3
及其以后的版本包含了JavaConfig
项目提供的大部分功能.
如果你的程序遭遇如下异常:
Exception
in thread "main" java.lang.annotation.AnnotationFormatError:
Invalid default: public abstract
org.springframework.beans.factory.annotation.Autowire
org.springframework.config.java.annotation.Configuration.defaultAutowire()
|
这很可能是因为你在Classpath
中添加了JavaConfig
项目release
出来的包(
比如
org.springframework.config.java-1.0.0.M4.jar
),
而在程序中使用JavaConfigApplicationContext
类。查看org.springframework.config.java-1.0.0.M4.jar
包的source code,
你会发现org.springframework.config.java.annotation.Configuration
类的defaultAutowire
的定义如下:
Autowire
defaultAutowire() default
Autowire
.INHERITED;
而查看org.springframework.beans.factory.annotation.Autowire
枚举类,你会发现INHERITED
根本就没有定义(
只有NO,
BY_NAME
和BY_TYPE
三种)
。这就难怪会报错了。
事实上,由于Spring 3.0M3
及其以后的版本包含了JavaConfig
项目提供的大部分功能,你无需为应用再添加JavaConfig
的包。@Configuration, @Bean
等都已经被整合到了org.springframework.context.annotation
下,
从文件来看就是org.springframework.context.jar
包。下图展示了一个可运行项目的Classpath
配置:
由于没有了JavaConfig
项目release
的包, JavaConfigApplicationContext
类也就无法找到了,你需要将它替换成org.springframework.context.annotation.AnnotationConfigApplicationContext,
例如:
public
static
void
main(String[]
args) {
ApplicationContext
context = new
AnnotationConfigApplicationContext(ApplicationConfig.class
);
String x =
context.getBean("x", String.class
);
System.out
.println("Got
x: " + x);
}
分享到:
相关推荐
Vue.config.js 是 Vue 3.0 中的一个重要配置文件,用于设置 Vue 项目的各种参数和选项。在本文中,我们将详细介绍 Vue.config.js 的配置项和使用方法。 基础配置 在 Vue 3.0 项目中,需要创建一个名为 `vue.config...
Finally, there is an attribute for checking authorization using Spring Security's Access Control Lists, which needs the specification of a domain object and the permissions defined on it that we are ...
Mybatis3.0是一款强大的Java持久层框架,它简化了数据访问层的开发,通过XML或注解方式灵活地映射SQL语句。这个压缩包包含的"Mybaits3.0代码示例(全)"提供了全面的增删改查操作,是初学者了解和学习Mybatis3.0的...
Spring Cloud Eureka是Spring Cloud框架中的一个核心组件,主要用于实现微服务之间的服务发现和服务治理。在微服务架构中,每个服务可能都会独立部署和扩展,Eureka作为一个服务注册中心,帮助各个服务实例进行注册...
* Spring enterprise: Spring Java EE integration, Spring Integration, Spring Batch, jBPM with Spring, Spring Remoting, messaging, transactions, scaling using Terracotta and GridGrain, and more. ...
Chapter 3 introduces you to how to manage the configuration of your microser- vices using Spring Cloud Config. Spring Cloud Config helps you guarantee that your service’s configuration information is...
Practical Spring LDAP is your guide to developing Java-based enterprise applications using the Spring LDAP Framework. This book explains the purpose and fundamental concepts of LDAP before giving a ...
When you become a Pivotal Certified Spring Web Application Developer, you'll receive one of the most valuable credentials available in enterprise Java. Achieving this certification demonstrates your ...
2. **动态SQL**:3.0版本加强了动态SQL的功能,允许在映射文件中编写条件语句,比如`if`, `choose`, `when`, `otherwise`, `where`, `foreach`等标签,这使得SQL的编写更加灵活,减少了重复代码。 3. **...
iBatis 3.0的配置文件(通常为`mybatis-config.xml`)是整个系统的核心,它定义了数据源、事务管理器、插件等全局配置。SqlSessionFactory则是根据配置文件创建的对象,用于生成SqlSession实例,它是执行SQL的入口...
README 中文版文档 This library shows you a gallery using ...Third step, init your GalleryRecyclerView in your java code just like using the normal RecyclerView. Note that you must use the LinearLayou
2. **配置**:Ibatis3.0的配置文件(mybatis-config.xml)包含了数据源、事务管理器等核心配置。此外,还支持基于Java的配置,允许在代码中动态创建SqlSessionFactory。 3. **SqlSession与SqlSessionFactory**:...
HBase3.0参考指南 This is the official reference guide for the HBase version it ships with. Herein you will find either the definitive documentation on an HBase topic as of its standing when the ...
You will learn to use these design patterns to solve common problems when designing an application or system using the Spring Framework. This book will not only take you through the essential GoF ...
主要介绍了Tomcat ssl报错Connector attribute SSLCertificateFile must be defined when using SSL with APR解决方法,需要的朋友可以参考下
You will also understand how to achieve authorization in a Spring WebFlux application using Spring Security.You will be able to explore the security confgurations required to achieve OAuth2 for ...
Integrate enterprise services to create a more complex Java application using Spring Boot Who This Book Is For Experienced Java and Spring programmers. Table of Contents Chapter 1: Spring Boot—...
在IT行业中,SpringMVC和MyBatis是两个非常重要的框架,它们被广泛应用于Java Web开发。本示例聚焦于如何在SpringMVC 3.0和MyBatis 3.0环境中实现分页功能,这在处理大量数据时尤其重要,能够提高用户体验并减轻...