springmvc启动报错,导入别人的项目 40C

Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in file [D:\apache-tomcat-8.5.27\webapps\ytxd-crm\WEB-INF\classes\config\spring\application-context-anontation.xml]: Cannot create inner bean 'com.bfgd.aop.SystemLogAspect#2f9b56ee' of type [com.bfgd.aop.SystemLogAspect] while setting bean property 'interceptors' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.bfgd.aop.SystemLogAspect#2f9b56ee': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bfgd.service.SystemLogService com.bfgd.aop.SystemLogAspect.systemLogService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'systemLogServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bfgd.common.dao.CommonDao com.bfgd.base.service.impl.BaseServiceImpl.commonDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'commonDaoImpl' defined in file [D:\apache-tomcat-8.5.27\webapps\ytxd-crm\WEB-INF\classes\com\bfgd\common\dao\impl\CommonDaoImpl.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in file [D:\apache-tomcat-8.5.27\webapps\ytxd-crm\WEB-INF\classes\config\spring\application-context-ds.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error the @annotation pointcut expression is only supported at Java 5 compliance level or above
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:153)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1141)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.bfgd.aop.SystemLogAspect#2f9b56ee': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bfgd.service.SystemLogService com.bfgd.aop.SystemLogAspect.systemLogService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'systemLogServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bfgd.common.dao.CommonDao com.bfgd.base.service.impl.BaseServiceImpl.commonDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'commonDaoImpl' defined in file [D:\apache-tomcat-8.5.27\webapps\ytxd-crm\WEB-INF\classes\com\bfgd\common\dao\impl\CommonDaoImpl.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in file [D:\apache-tomcat-8.5.27\webapps\ytxd-crm\WEB-INF\classes\config\spring\application-context-ds.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error the @annotation pointcut expression is only supported at Java 5 compliance level or above
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bfgd.service.SystemLogService com.bfgd.aop.SystemLogAspect.systemLogService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'systemLogServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bfgd.common.dao.CommonDao com.bfgd.base.service.impl.BaseServiceImpl.commonDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'commonDaoImpl' defined in file [D:\apache-tomcat-8.5.27\webapps\ytxd-crm\WEB-INF\classes\com\bfgd\common\dao\impl\CommonDaoImpl.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in file [D:\apache-tomcat-8.5.27\webapps\ytxd-crm\WEB-INF\classes\config\spring\application-context-ds.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error the @annotation pointcut expression is only supported at Java 5 compliance level or above
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
... 34 more

12个回答

supported at Java 5 compliance level 换jdk 用1.7或者1.8

wszj120
value_binfen 回复深爱甜蜜: 版本的问题: java.lang.IllegalArgumentException: error the @annotation pointcut expression is only supported at Java 5 compliance level or above 这是你的异常
一年多之前 回复
zhao5243
深爱甜蜜 jdk他那里用的1.6,所以我也用的1.6,版本应该没问题。
一年多之前 回复

以下是application-context-anontation.xml
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
default-autowire="byName"><!-- Notice:must be autowire:byName -->
<!-- -->
<!-- Annontation Handler -->

    <!-- 配置MVC的Action访问拦截器,可进行权限控制。与Filter作用类似。-->
    <property name="interceptors">       
     <list>
         <bean class="com.bfgd.aop.SystemLogAspect" />
     </list>
    </property>
</bean>

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" >
<property name="messageConverters">  
  <list>  
   <ref bean="mappingJacksonHttpMessageConverter" /><!-- json转换器 -->  
  </list>  
 </property> 
</bean>
<bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
<!--  -->
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>    
<!-- Anontation @Component scan... -->
<context:annotation-config />
<context:component-scan base-package="net.**.**.controller" />
<context:component-scan base-package="net.**.**.service.**"/>
<context:component-scan base-package="com.**.controller" />
<context:component-scan base-package="com.**.service.**"/>
<context:component-scan base-package="com.**.common.base"/>
<context:component-scan base-package="com.**.dao.**"/>

图片说明
文件结构是这样的,我也不知道这是什么结构,强行导入进来后,有些文件直接丢失了,然后再把丢失的文件复制到工程里去,再启动,就报这个错。

SystemLogAspect这个文件删掉,重新从仓库拉一下。

zhao5243
深爱甜蜜 试过了不行。
一年多之前 回复

看到这个错误信息了: @annotation pointcut expression is only supported at Java 5 compliance level or above ,应该是JDK版本太低了,需要JDK1.5以上

zhao5243
深爱甜蜜 jdk他那里用的1.6,所以我也用的1.6,版本应该没问题。
一年多之前 回复

图片说明
我把这些粘到工程里后,SystemLogAspect.java报错
package com.bfgd.aop;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import com.bfgd.service.SystemLogService;
import com.bfgd.common.model.SystemLog;
import com.bfgd.common.utils.DateUtils;
import com.bfgd.common.utils.IPUtil;
import com.bfgd.sysuser.model.SysUser;

public class SystemLogAspect implements HandlerInterceptor {

protected final Logger logger = LogManager.getLogger(this.getClass());

@Autowired
private SystemLogService systemLogService;
/**
 * 处理之前执行
 */
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    // 这里进行权限控制工作
    // logger.error("拦截器:*********Action之前执行**********");
    // return false;//不执行后续
    return true;// 执行后续
}

/**
 * 控制器执行完,生成视图之前可以执行,
 */
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
    // logger.error("拦截器:Action执行完,生成视图之前执行");
}

/**
 * 释放资源
 */
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {

    //  正则匹配到 /frame.html 则不记录 此条信息
    String requestURL = request.getRequestURI();
    if(requestURL.indexOf("frame.html") == -1){ //如果没有找到子字符串,则返回 -1
        SystemLog sysLog = new SystemLog();
        StringBuffer descArgs = new StringBuffer(200);

/*

Map map = request.getParameterMap();
Set keSet = map.entrySet();
for (Iterator itr = keSet.iterator(); itr.hasNext();) {
Map.Entry me = (Map.Entry) itr.next();
Object ok = me.getKey();
Object ov = me.getValue();
String[] value = new String[1];
if (ov instanceof String[]) {
value = (String[]) ov;
} else {
value[0] = ov.toString();
}
for (int k = 0, len = value.length; k < len; k++) {
descArgs.append(ok + "=" + value[k] + "&");
}
}

        sysLog.setOperateArgs(descArgs.toString());

*/

// 取到当前的操作用户
SysUser appUser = (SysUser) request.getSession().getAttribute("sysuser");
if (appUser != null) {
// 操作日志对象
sysLog.setSysUserId(appUser.getUserId());
}
sysLog.setUrl(requestURL);
sysLog.setOperateTime(DateUtils.getCurrentDateString());
sysLog.setOperateDes(handler.getClass().getName());
sysLog.setIp(IPUtil.getIpAddr(request));
// sysLog.setMac(IPUtil.getMacAddr(request));
systemLogService.addSystemLog(sysLog);
}

}

}

package那里就报错,The type javax.servlet.http.HttpServletResponse cannot be resolved. It is indirectly referenced from required .class files

SystemLogAspect类中的systemLogService属性无法autowired,应该是这个systemLogService这个接口没有实例化,导致找不到实例

smnzg
smnzg 回复深爱甜蜜: 包名是 com.bfgd.aop, 不是com.bfgd.common.aop
一年多之前 回复
zhao5243
深爱甜蜜 <context:component-scan base-package="com.bfgd.common.aop" /> <!-- --> <aop:aspectj-autoproxy proxy-target-class="true" /> 所以应该有实例。
一年多之前 回复
zhao5243
深爱甜蜜 在application-context-aop.xml中,
一年多之前 回复

又改了点东西后,错误又回到最初那个了。jdk我都改成1.8了,包括编译器什么的都改了,还是不行,所以应该不是jdk版本的问题。

有人能告诉我这个文件结构是怎么回事么?一个项目分成这三个文件,我不明白啊。

这个应该是分模块构建的项目,首先第一个项目应该是提取一些公共类作为父项目,第二个是具体业务实现,作为依赖于第一个项目的子项目,第三个项目应该就是放置一些公共依赖包。这样做的好处是便于扩展,降低耦合。我觉得你这个错误要么就是eclipse默认的jdk版本低于1.5导致的,之前我碰到过一次,改了jdk版本好像没变化,你可能没找对地方,还有可能就是lib包没有加入依赖包中,所以程序找不到加载路径。

zhao5243
深爱甜蜜 好的谢谢,听你这么一说,对于这个文件结构倒是理解一些了。
一年多之前 回复
共12条数据 1 尾页
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!