我正在尝试使用Spring来自动装配Jersey,但是只要其中一个方法被调用,我就会得到最奇怪的异常。
这是我的资源:
package fungle.funfinder.rest.resource;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.inject.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import fungle.common.hdao.model.ByteId;
import fungle.common.hdao.model.OnError;
import fungle.common.hdao.util.CascadeUtils;
import fungle.common.hdao.util.FetchUtils;
import fungle.funfinder.data.dao.ActivityTypeDAO;
import fungle.funfinder.data.entity.ActivityType;
@Path("activityType")
@Singleton
@Service
public class ActivityTypeResource {
private ActivityTypeDAO activityTypeDAO;
public ActivityTypeResource() {
}
public ActivityTypeResource(ActivityTypeDAO activityTypeDAO) {
this.activityTypeDAO=activityTypeDAO;
}
public ActivityTypeDAO getActivityTypeDAO() {
return activityTypeDAO;
}
@Autowired
public void setActivityTypeDAO(ActivityTypeDAO activityTypeDAO) {
this.activityTypeDAO = activityTypeDAO;
}
@GET
@Path("/all")
@Produces(value={MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
public List<ActivityType> getAll() {
Map<ByteId, ActivityType> types = activityTypeDAO.getAll(FetchUtils.always(),OnError.CONTINUE,null,null);
return new ArrayList<>(types.values());
}
@POST
public Response post(ActivityType activityType,@Context UriInfo uriInfo) {
ActivityType existing = activityTypeDAO.getByName(activityType.getName());
if (existing==null) {
activityTypeDAO.save(activityType, CascadeUtils.always(), OnError.ATTEMPT_UNDO);
existing = activityTypeDAO.getByName(activityType.getName());
if (existing !=null) {
// success
URI uri = uriInfo.getAbsolutePathBuilder().path(existing.getName()).build();
return Response.created(uri).build();
} else {
// failed to save.
return Response.serverError().build();
}
} else {
// already exists.
return Response.notModified("An activity type with that name already exists.").entity(existing).build();
}
}
@GET
@Path("/{name}")
public ActivityType getByName(@PathParam("name") String name) {
ActivityType existing = activityTypeDAO.getByName(name);
return existing;
}
}
这是我的maven依赖:tree:
[INFO] fungle:fungle.funfinder.data:jar:0.0.1-SNAPSHOT
[INFO] +- fungle:fungle.common.core:jar:0.0.1-SNAPSHOT:compile
[INFO] +- fungle:fungle.common.hdao:jar:0.0.1-SNAPSHOT:compile
[INFO] +- org.apache.avro:avro:jar:1.7.6:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.8.8:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.8.8:compile
[INFO] | +- com.thoughtworks.paranamer:paranamer:jar:2.3:compile
[INFO] | +- org.xerial.snappy:snappy-java:jar:1.0.5:compile
[INFO] | \- org.apache.commons:commons-compress:jar:1.4.1:compile
[INFO] | \- org.tukaani:xz:jar:1.0:compile
[INFO] +- org.apache.commons:commons-math3:jar:3.2:compile
[INFO] +- org.geotools:gt-referencing:jar:11.1:compile
[INFO] | +- java3d:vecmath:jar:1.3.2:compile
[INFO] | +- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] | +- org.geotools:gt-metadata:jar:11.1:compile
[INFO] | | \- org.geotools:gt-opengis:jar:11.1:compile
[INFO] | +- jgridshift:jgridshift:jar:1.0:compile
[INFO] | \- javax.media:jai_core:jar:1.1.3:compile
[INFO] +- org.geotools:gt-geometry:jar:11.1:compile
[INFO] | +- net.java.dev.jsr-275:jsr-275:jar:1.0-beta-2:compile
[INFO] | \- org.geotools:gt-main:jar:11.1:compile
[INFO] | +- org.geotools:gt-api:jar:11.1:compile
[INFO] | +- com.vividsolutions:jts:jar:1.13:compile
[INFO] | \- org.jdom:jdom:jar:1.1.3:compile
[INFO] +- org.geotools:gt-epsg-hsql:jar:11.1:compile
[INFO] | \- org.hsqldb:hsqldb:jar:2.2.8:compile
[INFO] +- org.springframework:spring-aspects:jar:4.0.2.RELEASE:compile
[INFO] | \- org.aspectj:aspectjweaver:jar:1.7.4:compile
[INFO] +- org.springframework:spring-context:jar:4.0.2.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:4.0.2.RELEASE:test
[INFO] +- org.springframework:spring-aop:jar:4.0.2.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-tx:jar:4.0.2.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:4.0.2.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] +- org.springframework:spring-beans:jar:4.0.2.RELEASE:compile
[INFO] +- org.springframework:spring-expression:jar:4.0.2.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:4.0.2.RELEASE:compile
[INFO] | \- org.springframework:spring-jdbc:jar:4.0.2.RELEASE:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.2:compile
[INFO] | \- ch.qos.logback:logback-core:jar:1.1.2:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.7:compile
[INFO] +- commons-cli:commons-cli:jar:20040117.000000:compile
[INFO] +- com.google.guava:guava:jar:17.0:compile
[INFO] +- org.apache.commons:commons-collections4:jar:4.0:compile
[INFO] +- commons-io:commons-io:jar:1.3.2:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] +- junit:junit:jar:4.11:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.apache.hadoop:hadoop-client:jar:2.0.0-cdh4.5.0:compile
[INFO] | +- org.apache.hadoop:hadoop-common:jar:2.0.0-cdh4.5.0:compile
[INFO] | | +- org.apache.commons:commons-math:jar:2.1:compile
[INFO] | | +- xmlenc:xmlenc:jar:0.52:compile
[INFO] | | +- commons-net:commons-net:jar:3.1:compile
[INFO] | | +- commons-el:commons-el:jar:1.0:runtime
[INFO] | | +- org.apache.hadoop:cloudera-jets3t:jar:2.0.0-cdh4.5.0:compile
[INFO] | | +- org.mockito:mockito-all:jar:1.8.5:compile
[INFO] | | +- org.apache.hadoop:hadoop-auth:jar:2.0.0-cdh4.5.0:compile
[INFO] | | \- com.jcraft:jsch:jar:0.1.42:compile
[INFO] | +- org.apache.hadoop:hadoop-hdfs:jar:2.0.0-cdh4.5.0:compile
[INFO] | +- org.apache.hadoop:hadoop-mapreduce-client-app:jar:2.0.0-cdh4.5.0:compile
[INFO] | | +- org.apache.hadoop:hadoop-mapreduce-client-common:jar:2.0.0-cdh4.5.0:compile
[INFO] | | | +- org.apache.hadoop:hadoop-yarn-client:jar:2.0.0-cdh4.5.0:compile
[INFO] | | | \- org.apache.hadoop:hadoop-yarn-server-common:jar:2.0.0-cdh4.5.0:compile
[INFO] | | +- org.apache.hadoop:hadoop-mapreduce-client-shuffle:jar:2.0.0-cdh4.5.0:compile
[INFO] | | \- org.jboss.netty:netty:jar:3.2.4.Final:compile
[INFO] | +- org.apache.hadoop:hadoop-yarn-api:jar:2.0.0-cdh4.5.0:compile
[INFO] | +- org.apache.hadoop:hadoop-mapreduce-client-core:jar:2.0.0-cdh4.5.0:compile
[INFO] | | \- org.apache.hadoop:hadoop-yarn-common:jar:2.0.0-cdh4.5.0:compile
[INFO] | +- org.apache.hadoop:hadoop-mapreduce-client-jobclient:jar:2.0.0-cdh4.5.0:compile
[INFO] | \- org.apache.hadoop:hadoop-annotations:jar:2.0.0-cdh4.5.0:compile
[INFO] \- org.apache.hbase:hbase:jar:0.94.6-cdh4.5.0:compile
[INFO] +- com.yammer.metrics:metrics-core:jar:2.1.2:compile
[INFO] +- commons-configuration:commons-configuration:jar:1.6:compile
[INFO] | +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] | +- commons-digester:commons-digester:jar:1.8:compile
[INFO] | | \- commons-beanutils:commons-beanutils:jar:1.7.0:compile
[INFO] | \- commons-beanutils:commons-beanutils-core:jar:1.8.0:compile
[INFO] +- com.github.stephenc.high-scale-lib:high-scale-lib:jar:1.1.1:compile
[INFO] +- commons-codec:commons-codec:jar:20041127.091804:compile (version managed from 1.4)
[INFO] +- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] +- commons-lang:commons-lang:jar:2.5:compile
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] +- org.apache.zookeeper:zookeeper:jar:3.4.5-cdh4.5.0:compile
[INFO] +- org.apache.thrift:libthrift:jar:0.9.0:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.3.1:compile (version managed from 4.1.3)
[INFO] | \- org.apache.httpcomponents:httpcore:jar:4.1.3:compile
[INFO] +- org.jruby:jruby-complete:jar:1.6.5:compile
[INFO] +- org.mortbay.jetty:jetty:jar:6.1.26.cloudera.2:compile
[INFO] +- org.mortbay.jetty:jetty-util:jar:6.1.26.cloudera.2:compile
[INFO] +- org.mortbay.jetty:jsp-2.1:jar:6.1.14:compile
[INFO] | \- org.eclipse.jdt:core:jar:3.1.1:compile
[INFO] +- org.mortbay.jetty:jsp-api-2.1:jar:6.1.14:compile
[INFO] +- org.codehaus.jackson:jackson-jaxrs:jar:1.8.8:compile
[INFO] +- org.codehaus.jackson:jackson-xc:jar:1.8.8:compile
[INFO] +- tomcat:jasper-compiler:jar:5.5.23:runtime
[INFO] +- tomcat:jasper-runtime:jar:5.5.23:runtime
[INFO] +- org.jamon:jamon-runtime:jar:2.3.1:compile
[INFO] +- com.google.protobuf:protobuf-java:jar:2.4.0a:compile
[INFO] +- javax.xml.bind:jaxb-api:jar:2.1:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] \- stax:stax-api:jar:1.0.1:compile
我不确定这是否相关,但我有一段时间有一些球衣罐冲突,我的hadoop罐装了一些球衣文物,所以我在我的pom中扔了一些排除如下:
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<artifactId>
jersey-test-framework-grizzly2
</artifactId>
<groupId>
com.sun.jersey.jersey-test-framework
</groupId>
</exclusion>
<exclusion>
<artifactId>jersey-guice</artifactId>
<groupId>com.sun.jersey.contribs</groupId>
</exclusion>
<exclusion>
<artifactId>jersey-server</artifactId>
<groupId>com.sun.jersey</groupId>
</exclusion>
<exclusion>
<artifactId>jersey-core</artifactId>
<groupId>com.sun.jersey</groupId>
</exclusion>
<exclusion>
<artifactId>jersey-json</artifactId>
<groupId>com.sun.jersey</groupId>
</exclusion>
</exclusions>
</dependency>
因此,当我运行我的网络应用程序时,一切似乎都很好,直到我的jsp页面加载时调用该资源。这是堆栈跟踪:
SEVERE: Servlet.service() for servlet [jersey] in context with path [/fungle.funfinder.web] threw exception [A MultiException has 3 exceptions. They are:
1. java.lang.ClassCastException: java.lang.reflect.Method cannot be cast to java.lang.reflect.Constructor
2. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of fungle.funfinder.rest.resource.ActivityTypeResource errors were found
3. java.lang.IllegalStateException: Unable to perform operation: resolve on fungle.funfinder.rest.resource.ActivityTypeResource
] with root cause
java.lang.ClassCastException: java.lang.reflect.Method cannot be cast to java.lang.reflect.Constructor
at org.glassfish.jersey.server.spring.AutowiredInjectResolver.createSpringDependencyDescriptor(AutowiredInjectResolver.java:114)
at org.glassfish.jersey.server.spring.AutowiredInjectResolver.getBeanFromSpringContext(AutowiredInjectResolver.java:97)
at org.glassfish.jersey.server.spring.AutowiredInjectResolver.resolve(AutowiredInjectResolver.java:92)
at org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:214)
at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:244)
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:360)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:114)
at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:102)
at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture$1.call(Cache.java:97)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture.run(Cache.java:154)
at org.glassfish.hk2.utilities.cache.Cache.compute(Cache.java:199)
at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:153)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2151)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:641)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:626)
at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:172)
at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:185)
at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:74)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115)
at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:94)
at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:63)
at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:261)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:297)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:252)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1025)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:372)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:382)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:345)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:220)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:744)
我也可以发布我的任何应用上下文和/或web xml文件,只是这个帖子已经很长了,我认为这可能是一个类路径问题。如果你想看到那些,请告诉我。
请告诉我我做错了什么。
==================================
编辑:我刚刚将自动装配移动到构造函数,现在它正在毫无例外地工作。不过,出于各种原因,我可能需要在将来使用setter方法。有人请告诉我为什么它在我自动装箱机时失败了?这是一个错误吗?
答案 0 :(得分:2)
我自己跑了过来,这是泽西岛的一个错误(JERSEY-2681)。看起来Jersey代码正在重新实现一些Spring自动装配逻辑,并且缺少setter方法案例。如果我们深入研究抛出异常的AutowiredInjectResolver类的实现,您可以看到方法自动装配情况没有被考虑在内;如果自动装配的元素不是字段,则代码假定它是构造函数。因此,在自动装配方法的情况下,抛出ClassCastException。
private DependencyDescriptor createSpringDependencyDescriptor(final Injectee injectee) {
AnnotatedElement annotatedElement = injectee.getParent();
if (annotatedElement.getClass().isAssignableFrom(Field.class)) {
return new DependencyDescriptor((Field) annotatedElement,
!injectee.isOptional());
} else {
return new DependencyDescriptor(
new MethodParameter((Constructor) annotatedElement, injectee.getPosition()), !injectee.isOptional());
}
}
如果您不想使用构造函数注入,则字段注入仍然有效。所以你可以使用@Autowired
注释该字段,一切都应该有效。哎呀,如果你想要或者需要它,你仍然可以保持它的位置。
@Autowired
private ActivityTypeDAO activityTypeDAO;
public void setActivityTypeDAO(ActivityTypeDAO activityTypeDAO) {
this.activityTypeDAO = activityTypeDAO;
}
那就是说,我知道这可能不是你想要遵循的模式,但在泽西修复之前,看起来你必须做一些变通办法。