我是靠谱客的博主 内向月亮,最近开发中收集的这篇文章主要介绍按图索骥法解决错误,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

      编程时难免会遇到各种错误,我以往的解决方法是查资料,将相关的技术资料学习一遍,将这些技术细节都搞明白了再来解决问题,这种方法费时费力,效率极其低下。因此,需要用高效的方法来解决错误,本文以本人经历过的例子来解释这种方法。

     本文所涉及到的程序的开发环境是ideaMaven,编程语言是java,用到的框架是spring

实例一:

pom.xml内某些依赖无<version>,执行clean操作后terminal的输出信息:

/home/linux2014/WJT_2017/soft_intsall/jdk18/bin/java-Dmaven.multiModuleProjectDirectory=/home/linux2014/WJT_2017/projects/idea_projects/wjt_train_170622/springMVC_170726-Dmaven.home=/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/plugins/maven/lib/maven3-Dclassworlds.conf=/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/plugins/maven/lib/maven3/bin/m2.conf-javaagent:/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/lib/idea_rt.jar=59772:/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/bin-Dfile.encoding=UTF-8 -classpath/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/plugins/maven/lib/maven3/boot/plexus-classworlds-2.5.2.jarorg.codehaus.classworlds.Launcher -Didea.version=2017.1.2 clean

[INFO]Scanning for projects...

[ERROR][ERROR] Some problems were encountered while processing the POMs:

[FATAL]'version' is missing. @ line 2, column 106

@

[ERROR]The build could not read 1 project -> [Help 1]

[ERROR]

[ERROR] The project com.qunar.fresh2017:springMVC_170726:[unknown-version](/home/linux2014/WJT_2017/projects/idea_projects/wjt_train_170622/springMVC_170726/pom.xml)has 1 error

[ERROR] 'version' is missing. @ line 2, column 106

[ERROR]

[ERROR]To see the full stack trace of the errors, re-run Maven with the -eswitch.

[ERROR]Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR]For more information about the errors and possible solutions, pleaseread the following articles:

[ERROR][Help 1]http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException


Processfinished with exit code 1




从这些提示信息可看出,错误源于version丢失,利用mvn-e可看到完整的栈追踪错误,利用mvn-X可看到全部的调试日志。


linux2014@linux2014-Latitude-E5440:~/WJT_2017/projects/idea_projects/wjt_train_170622/springMVC_170726$mvn -e

[INFO]Error stacktraces are turned on.

[INFO]Scanning for projects...

[ERROR]The build could not read 1 project -> [Help 1]

org.apache.maven.project.ProjectBuildingException:Some problems were encountered while processing the POMs:

[FATAL]'version' is missing. @ line 2, column 106


atorg.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:363)

atorg.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:636)

atorg.apache.maven.DefaultMaven.getProjectsForMavenReactor(DefaultMaven.java:585)

atorg.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:234)

atorg.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)

atorg.apache.maven.cli.MavenCli.execute(MavenCli.java:537)

atorg.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)

atorg.apache.maven.cli.MavenCli.main(MavenCli.java:141)

atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

atjava.lang.reflect.Method.invoke(Method.java:498)

atorg.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)

atorg.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)

atorg.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)

atorg.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

[ERROR]

[ERROR] The project com.qunar.fresh2017:springMVC_170726:[unknown-version](/home/linux2014/WJT_2017/projects/idea_projects/wjt_train_170622/springMVC_170726/pom.xml)has 1 error

[ERROR] 'version' is missing. @ line 2, column 106

[ERROR]

[ERROR]Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR]For more information about the errors and possible solutions, pleaseread the following articles:

[ERROR][Help 1]http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException


linux2014@linux2014-Latitude-E5440:~/WJT_2017/projects/idea_projects/wjt_train_170622/springMVC_170726$mvn -X

ApacheMaven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-1921:51:28+0800)

Mavenhome: /home/linux2014/WJT_2017/soft_intsall/apache-maven-3.0.5

Javaversion: 1.8.0_131, vendor: Oracle Corporation

Javahome: /home/linux2014/WJT_2017/soft_intsall/jdk18/jre

Defaultlocale: zh_CN, platform encoding: UTF-8

OSname: "linux", version: "3.13.0-121-generic",arch: "amd64", family: "unix"

[INFO]Error stacktraces are turned on.

[DEBUG]Reading global settings from/home/linux2014/WJT_2017/soft_intsall/apache-maven-3.0.5/conf/settings.xml

[DEBUG]Reading user settings from /home/linux2014/.m2/settings.xml

[DEBUG]Using local repository at /home/linux2014/.m2/repository

[DEBUG]Using manager EnhancedLocalRepositoryManager with priority 10 for/home/linux2014/.m2/repository

[DEBUG]Failed to decrypt password for server releases:org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException:java.io.FileNotFoundException:/home/linux2014/.m2/settings-security.xml (没有那个文件或目录)

org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException:org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException:java.io.FileNotFoundException:/home/linux2014/.m2/settings-security.xml (没有那个文件或目录)

atorg.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher.decrypt(DefaultSecDispatcher.java:121)

atorg.apache.maven.settings.crypto.DefaultSettingsDecrypter.decrypt(DefaultSettingsDecrypter.java:106)

atorg.apache.maven.settings.crypto.DefaultSettingsDecrypter.decrypt(DefaultSettingsDecrypter.java:62)

atorg.apache.maven.DefaultMaven.newRepositorySession(DefaultMaven.java:381)

atorg.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:208)

atorg.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)

atorg.apache.maven.cli.MavenCli.execute(MavenCli.java:537)

atorg.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)

atorg.apache.maven.cli.MavenCli.main(MavenCli.java:141)

atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

atjava.lang.reflect.Method.invoke(Method.java:498)

atorg.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)

atorg.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)

atorg.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)

atorg.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

Causedby:org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException:java.io.FileNotFoundException:/home/linux2014/.m2/settings-security.xml (没有那个文件或目录)

atorg.sonatype.plexus.components.sec.dispatcher.SecUtil.read(SecUtil.java:69)

atorg.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher.getSec(DefaultSecDispatcher.java:206)

atorg.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher.decrypt(DefaultSecDispatcher.java:90)

...16 more

Causedby: java.io.FileNotFoundException:/home/linux2014/.m2/settings-security.xml (没有那个文件或目录)

atjava.io.FileInputStream.open0(Native Method)

atjava.io.FileInputStream.open(FileInputStream.java:195)

atjava.io.FileInputStream.<init>(FileInputStream.java:138)

atorg.sonatype.plexus.components.sec.dispatcher.SecUtil.toStream(SecUtil.java:100)

atorg.sonatype.plexus.components.sec.dispatcher.SecUtil.read(SecUtil.java:56)

...18 more

[INFO]Scanning for projects...

[ERROR]The build could not read 1 project -> [Help 1]

org.apache.maven.project.ProjectBuildingException:Some problems were encountered while processing the POMs:

[FATAL]'version' is missing. @ line 2, column 106


atorg.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:363)

atorg.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:636)

atorg.apache.maven.DefaultMaven.getProjectsForMavenReactor(DefaultMaven.java:585)

atorg.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:234)

atorg.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)

atorg.apache.maven.cli.MavenCli.execute(MavenCli.java:537)

atorg.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)

atorg.apache.maven.cli.MavenCli.main(MavenCli.java:141)

atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

atjava.lang.reflect.Method.invoke(Method.java:498)

atorg.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)

atorg.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)

atorg.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)

atorg.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

[ERROR]

[ERROR] The project com.qunar.fresh2017:springMVC_170726:[unknown-version](/home/linux2014/WJT_2017/projects/idea_projects/wjt_train_170622/springMVC_170726/pom.xml)has 1 error

[ERROR] 'version' is missing. @ line 2, column 106

[ERROR]

[ERROR]

[ERROR]For more information about the errors and possible solutions, pleaseread the following articles:

[ERROR][Help 1]http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException


从这些调试信息可以看出:错误源于pom.xml内的version缺失,因此添加上version,再执行clean和compile命令。执行clean命令的结果如下:

/home/linux2014/WJT_2017/soft_intsall/jdk18/bin/java-Dmaven.multiModuleProjectDirectory=/home/linux2014/WJT_2017/projects/idea_projects/wjt_train_170622/springMVC_170726-Dmaven.home=/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/plugins/maven/lib/maven3-Dclassworlds.conf=/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/plugins/maven/lib/maven3/bin/m2.conf-javaagent:/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/lib/idea_rt.jar=43818:/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/bin-Dfile.encoding=UTF-8 -classpath/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/plugins/maven/lib/maven3/boot/plexus-classworlds-2.5.2.jarorg.codehaus.classworlds.Launcher -Didea.version=2017.1.2 clean

[INFO]Scanning for projects...

[INFO]

[INFO]------------------------------------------------------------------------

[INFO]Building springMVC_170726 Maven Webapp 1.0-SNAPSHOT

[INFO]------------------------------------------------------------------------

[INFO]

[INFO]--- maven-clean-plugin:2.5:clean (default-clean) @ springMVC_170726---

[INFO]Deleting/home/linux2014/WJT_2017/projects/idea_projects/wjt_train_170622/springMVC_170726/target

[INFO]------------------------------------------------------------------------

[INFO]BUILD SUCCESS

[INFO]------------------------------------------------------------------------

[INFO]Total time: 0.271 s

[INFO]Finished at: 2017-07-26T19:33:53+08:00

[INFO]Final Memory: 5M/150M

[INFO]------------------------------------------------------------------------


Processfinished with exit code 0


执行compile命令。

/home/linux2014/WJT_2017/soft_intsall/jdk18/bin/java-Dmaven.multiModuleProjectDirectory=/home/linux2014/WJT_2017/projects/idea_projects/wjt_train_170622/springMVC_170726-Dmaven.home=/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/plugins/maven/lib/maven3-Dclassworlds.conf=/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/plugins/maven/lib/maven3/bin/m2.conf-javaagent:/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/lib/idea_rt.jar=55258:/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/bin-Dfile.encoding=UTF-8 -classpath/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/plugins/maven/lib/maven3/boot/plexus-classworlds-2.5.2.jarorg.codehaus.classworlds.Launcher -Didea.version=2017.1.2 compile

[INFO]Scanning for projects...

[INFO]

[INFO]------------------------------------------------------------------------

[INFO]Building springMVC_170726 Maven Webapp 1.0-SNAPSHOT

[INFO]------------------------------------------------------------------------

[INFO]

[INFO]--- maven-resources-plugin:2.6:resources (default-resources) @springMVC_170726 ---

[WARNING]Using platform encoding (UTF-8 actually) to copy filtered resources,i.e. build is platform dependent!

[INFO]Copying 7 resources

[INFO]

[INFO]--- maven-compiler-plugin:3.1:compile (default-compile) @springMVC_170726 ---

[INFO]Nothing to compile - all classes are up to date

[INFO]------------------------------------------------------------------------

[INFO]BUILD SUCCESS

[INFO]------------------------------------------------------------------------

[INFO]Total time: 0.832 s

[INFO]Finished at: 2017-07-31T10:39:48+08:00

[INFO]Final Memory: 9M/212M

[INFO]------------------------------------------------------------------------


Processfinished with exit code 0

实例二:

应用aop编程,配置文件c4_aop.xml如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd">

    <context:component-scan base-package="springInAction_c4"></context:component-scan>
    
    <aop:config>
        <aop:aspect ref="audience">
            <aop:before pointcut="execution(* springInAction_c4.Performer.perform(..))" method="takeSeats"/>
            <aop:before pointcut="execution(* springInAction_c4.Performer.perform(..))" method="turnOffCellPhones"/>
            <aop:after-returning pointcut="execution(* springInAction_c4.Performer.perform(..))" method="applaud"/>
            <aop:after-throwing pointcut="execution(* springInAction_c4.Performer.perform(..))" method="demandRefund"/>
        </aop:aspect>
    </aop:config>
</beans>

执行测试用例时控制台的输出:

/home/linux2014/WJT_2017/soft_intsall/jdk18/bin/java-ea -Didea.test.cyclic.buffer.size=1048576-javaagent:/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/lib/idea_rt.jar=53441:/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/bin-Dfile.encoding=UTF-8 -classpath/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/lib/idea_rt.jar:/home/linux2014/WJT_2017/soft_intsall/idea_IU_17/plugins/junit/lib/junit-rt.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/charsets.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/deploy.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/ext/cldrdata.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/ext/dnsns.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/ext/jaccess.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/ext/jfxrt.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/ext/localedata.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/ext/nashorn.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/ext/sunec.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/ext/sunjce_provider.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/ext/sunpkcs11.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/ext/zipfs.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/javaws.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/jce.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/jfr.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/jfxswt.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/jsse.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/management-agent.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/plugin.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/resources.jar:/home/linux2014/WJT_2017/soft_intsall/jdk18/jre/lib/rt.jar:/home/linux2014/WJT_2017/projects/idea_projects/wjt_train_170622/springMVC_170726/target/test-classes:/home/linux2014/WJT_2017/projects/idea_projects/wjt_train_170622/springMVC_170726/target/classes:/home/linux2014/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/linux2014/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/home/linux2014/.m2/repository/joda-time/joda-time/2.9.9/joda-time-2.9.9.jar:/home/linux2014/.m2/repository/org/springframework/spring-context/3.2.6.RELEASE/spring-context-3.2.6.RELEASE.jar:/home/linux2014/.m2/repository/org/springframework/spring-beans/3.2.6.RELEASE/spring-beans-3.2.6.RELEASE.jar:/home/linux2014/.m2/repository/org/springframework/spring-core/3.2.6.RELEASE/spring-core-3.2.6.RELEASE.jar:/home/linux2014/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/home/linux2014/.m2/repository/org/springframework/spring-expression/3.2.6.RELEASE/spring-expression-3.2.6.RELEASE.jar:/home/linux2014/.m2/repository/org/springframework/spring-aop/3.2.6.RELEASE/spring-aop-3.2.6.RELEASE.jar:/home/linux2014/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/home/linux2014/.m2/repository/org/aspectj/aspectjweaver/1.8.10/aspectjweaver-1.8.10.jar:/home/linux2014/.m2/repository/cglib/cglib-nodep/3.2.0/cglib-nodep-3.2.0.jar:/home/linux2014/.m2/repository/org/mockito/mockito-core/1.8.0/mockito-core-1.8.0.jar:/home/linux2014/.m2/repository/org/objenesis/objenesis/1.0/objenesis-1.0.jar:/home/linux2014/.m2/repository/org/mockito/mockito-all/1.8.0/mockito-all-1.8.0.jar:/home/linux2014/.m2/repository/org/slf4j/slf4j-api/1.7.9/slf4j-api-1.7.9.jar:/home/linux2014/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.9/jcl-over-slf4j-1.7.9.jar:/home/linux2014/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/home/linux2014/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/home/linux2014/.m2/repository/org/projectlombok/lombok/1.16.0/lombok-1.16.0.jarcom.intellij.rt.execution.junit.JUnitStarter -ideVersion5springInAction_c4.AudienceTest,func1

10:47:28.625[main] DEBUG org.springframework.core.env.StandardEnvironment -Initializing new StandardEnvironment

10:47:28.636[main] DEBUG org.springframework.core.env.StandardEnvironment -Adding [systemProperties] PropertySource with lowest searchprecedence

10:47:28.638[main] DEBUG org.springframework.core.env.StandardEnvironment -Adding [systemEnvironment] PropertySource with lowest searchprecedence

10:47:28.638[main] DEBUG org.springframework.core.env.StandardEnvironment -Initialized StandardEnvironment with PropertySources[systemProperties,systemEnvironment]

10:47:28.643[main] INFOorg.springframework.context.support.ClassPathXmlApplicationContext -Refreshingorg.springframework.context.support.ClassPathXmlApplicationContext@4c203ea1:startup date [Mon Jul 31 10:47:28 CST 2017]; root of contexthierarchy

10:47:28.692[main] DEBUG org.springframework.core.env.StandardEnvironment -Initializing new StandardEnvironment

10:47:28.693[main] DEBUG org.springframework.core.env.StandardEnvironment -Adding [systemProperties] PropertySource with lowest searchprecedence

10:47:28.694[main] DEBUG org.springframework.core.env.StandardEnvironment -Adding [systemEnvironment] PropertySource with lowest searchprecedence

10:47:28.695[main] DEBUG org.springframework.core.env.StandardEnvironment -Initialized StandardEnvironment with PropertySources[systemProperties,systemEnvironment]

10:47:28.705[main] INFOorg.springframework.beans.factory.xml.XmlBeanDefinitionReader -Loading XML bean definitions from class path resource [c4/c4_aop.xml]

10:47:28.723[main] DEBUGorg.springframework.beans.factory.xml.DefaultDocumentLoader - UsingJAXP provider[com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl]

10:47:28.818[main] DEBUGorg.springframework.beans.factory.xml.PluggableSchemaResolver -Loading schema mappings from [META-INF/spring.schemas]

10:47:28.823[main] DEBUGorg.springframework.beans.factory.xml.PluggableSchemaResolver -Loaded schema mappings:{http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-3.2.xsd,http://www.springframework.org/schema/jee/spring-jee-3.2.xsd=org/springframework/ejb/config/spring-jee-3.2.xsd,http://www.springframework.org/schema/beans/spring-beans-3.1.xsd=org/springframework/beans/factory/xml/spring-beans-3.1.xsd,http://www.springframework.org/schema/task/spring-task.xsd=org/springframework/scheduling/config/spring-task-3.2.xsd,http://www.springframework.org/schema/cache/spring-cache.xsd=org/springframework/cache/config/spring-cache-3.2.xsd,http://www.springframework.org/schema/aop/spring-aop-3.0.xsd=org/springframework/aop/config/spring-aop-3.0.xsd,http://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd,http://www.springframework.org/schema/task/spring-task-3.1.xsd=org/springframework/scheduling/config/spring-task-3.1.xsd,http://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd,http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.2.xsd,http://www.springframework.org/schema/jee/spring-jee-2.5.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd,http://www.springframework.org/schema/tool/spring-tool-3.1.xsd=org/springframework/beans/factory/xml/spring-tool-3.1.xsd,http://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-3.2.xsd,http://www.springframework.org/schema/jee/spring-jee-3.1.xsd=org/springframework/ejb/config/spring-jee-3.1.xsd,http://www.springframework.org/schema/context/spring-context-3.2.xsd=org/springframework/context/config/spring-context-3.2.xsd,http://www.springframework.org/schema/util/spring-util-3.2.xsd=org/springframework/beans/factory/xml/spring-util-3.2.xsd,http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd,http://www.springframework.org/schema/lang/spring-lang-3.2.xsd=org/springframework/scripting/config/spring-lang-3.2.xsd,http://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd,http://www.springframework.org/schema/cache/spring-cache-3.2.xsd=org/springframework/cache/config/spring-cache-3.2.xsd,http://www.springframework.org/schema/task/spring-task-3.0.xsd=org/springframework/scheduling/config/spring-task-3.0.xsd,http://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd,http://www.springframework.org/schema/tool/spring-tool-3.0.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd,http://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd,http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd,http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-3.2.xsd,http://www.springframework.org/schema/lang/spring-lang-2.5.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd,http://www.springframework.org/schema/aop/spring-aop-3.2.xsd=org/springframework/aop/config/spring-aop-3.2.xsd,http://www.springframework.org/schema/jee/spring-jee-3.0.xsd=org/springframework/ejb/config/spring-jee-3.0.xsd,http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd,http://www.springframework.org/schema/context/spring-context-3.1.xsd=org/springframework/context/config/spring-context-3.1.xsd,http://www.springframework.org/schema/util/spring-util-3.1.xsd=org/springframework/beans/factory/xml/spring-util-3.1.xsd,http://www.springframework.org/schema/lang/spring-lang-3.1.xsd=org/springframework/scripting/config/spring-lang-3.1.xsd,http://www.springframework.org/schema/cache/spring-cache-3.1.xsd=org/springframework/cache/config/spring-cache-3.1.xsd,http://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.2.xsd,http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-3.2.xsd,http://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd,http://www.springframework.org/schema/beans/spring-beans-3.2.xsd=org/springframework/beans/factory/xml/spring-beans-3.2.xsd,http://www.springframework.org/schema/aop/spring-aop-3.1.xsd=org/springframework/aop/config/spring-aop-3.1.xsd,http://www.springframework.org/schema/task/spring-task-3.2.xsd=org/springframework/scheduling/config/spring-task-3.2.xsd,http://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd,http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-3.2.xsd,http://www.springframework.org/schema/util/spring-util-3.0.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd,http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd,http://www.springframework.org/schema/lang/spring-lang-3.0.xsd=org/springframework/scripting/config/spring-lang-3.0.xsd,http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd,http://www.springframework.org/schema/tool/spring-tool-3.2.xsd=org/springframework/beans/factory/xml/spring-tool-3.2.xsd,http://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd}

10:47:28.825[main] DEBUGorg.springframework.beans.factory.xml.PluggableSchemaResolver - FoundXML schema[http://www.springframework.org/schema/beans/spring-beans-3.0.xsd] inclasspath: org/springframework/beans/factory/xml/spring-beans-3.0.xsd

10:47:28.911[main] DEBUGorg.springframework.beans.factory.xml.PluggableSchemaResolver - FoundXML schema[http://www.springframework.org/schema/context/spring-context.xsd] inclasspath: org/springframework/context/config/spring-context-3.2.xsd

10:47:28.929[main] DEBUGorg.springframework.beans.factory.xml.PluggableSchemaResolver - FoundXML schema[http://www.springframework.org/schema/tool/spring-tool-3.2.xsd] inclasspath: org/springframework/beans/factory/xml/spring-tool-3.2.xsd


org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:Line 14 in XML document from class path resource [c4/c4_aop.xml] isinvalid; nested exception is org.xml.sax.SAXParseException;lineNumber: 14; columnNumber: 17; cvc-complex-type.2.4.c:通配符的匹配很全面,但无法找到元素'aop:config'的声明。


atorg.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)

atorg.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)

atorg.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)

atorg.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)

atorg.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)

atorg.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)

atorg.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)

atorg.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)

atorg.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)

atorg.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)

atorg.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)

atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)

atorg.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)

atorg.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)

atspringInAction_c4.AudienceTest.func1(AudienceTest.java:17)

atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

atjava.lang.reflect.Method.invoke(Method.java:498)

atorg.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

atorg.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

atorg.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

atorg.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

atorg.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

atorg.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)

atorg.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)

atorg.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

atorg.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

atorg.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

atorg.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

atorg.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

atorg.junit.runners.ParentRunner.run(ParentRunner.java:363)

atorg.junit.runner.JUnitCore.run(JUnitCore.java:137)

atcom.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)

atcom.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)

atcom.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)

atcom.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Causedby: org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 17;cvc-complex-type.2.4.c:通配符的匹配很全面,但无法找到元素'aop:config'的声明。

atcom.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)

atcom.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)

atcom.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)

atcom.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)

atcom.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)

atcom.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:452)

atcom.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3230)

atcom.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1911)

atcom.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:740)

atcom.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:374)

atcom.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784)

atcom.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)

atcom.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)

atcom.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)

atcom.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)

atcom.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)

atcom.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)

atcom.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)

atcom.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)

atorg.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)

atorg.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)

...36 more



Processfinished with exit code 255


根据红色文字的提示可知:错误源于c4_aop.xml文件内缺少对aop:config的配置,定位到问题后,结合百度搜索可找到解决办法:在c4_aop.xml内添加对aop命名空间的声明。修改后的c4_aop.xml文件如下(红色字符串即为添加的aop命名空间):

<?xml
version="1.0"
encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xmlns:aop="http://www.springframework.org/schema/aop"

      xmlns:context="http://www.springframework.org/schema/context"

      xsi:schemaLocation="http://www.springframework.org/schema/beans
  
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  
    http://www.springframework.org/schema/context
  
    http://www.springframework.org/schema/context/spring-context.xsd
  
    http://www.springframework.org/schema/aop
  
    http://www.springframework.org/schema/aop/spring-aop.xsd">

   <context:component-scan base-package="springInAction_c4"></context:component-scan>

   <aop:config>

       <aop:aspect ref="audience">

           <aop:before pointcut="execution(* springInAction_c4.Performer.perform(..))" method="takeSeats"/>

           <aop:before pointcut="execution(* springInAction_c4.Performer.perform(..))" method="turnOffCellPhones"/>

           <aop:after-returning pointcut="execution(* springInAction_c4.Performer.perform(..))" method="applaud"/>

           <aop:after-throwing pointcut="execution(* springInAction_c4.Performer.perform(..))" method="demandRefund"/>

       </aop:aspect>

   </aop:config>
</beans>
c4_aop.xml文件修改之后程序可正常运行。


根据错误提示来定位错误,采用“猜”、“试”相结合的方法解决错误,这种方法不需要全面掌握相关知识点,而且纠错效率较高。这就是本文题目所说的“按图索骥法”。


最后

以上就是内向月亮为你收集整理的按图索骥法解决错误的全部内容,希望文章能够帮你解决按图索骥法解决错误所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(36)

评论列表共有 0 条评论

立即
投稿
返回
顶部