老师你好,STS中运行不报错。用打完的war包运行报错不知道是为什么

来源:13-13 项目的打包与部署

zhldt

2019-03-12

D:\JAVA_EE\spring-boot\bookstore>cd target

D:\JAVA_EE\spring-boot\bookstore\target>java -jar book-0.0.1-SNAPSHOT.war

. ____ _ __ _ _
/\ / __ _ () __ __ _ \ \ \
( ( )_
_ | '_ | '| | ’ / ` | \ \ \
\/ )| |)| | | | | || (| | ) ) ) )
’ |
| .__|| ||| |__, | / / / /
=|_|======|/=////
:: Spring Boot :: (v1.5.19.RELEASE)

2019-03-12 23:20:34.950 [main] INFO com.zhl.book.BookstoreApplication - Startin
g BookstoreApplication v0.0.1-SNAPSHOT on X4MGJ2CVG3I48ZF with PID 7684 (D:\JAVA
_EE\spring-boot\bookstore\target\book-0.0.1-SNAPSHOT.war started by Administrato
r in D:\JAVA_EE\spring-boot\bookstore\target)
2019-03-12 23:20:34.955 [main] INFO com.zhl.book.BookstoreApplication - No acti
ve profile set, falling back to default profiles: default
2019-03-12 23:20:35.080 [main] INFO o.s.b.c.e.AnnotationConfigEmbeddedWebApplic
ationContext - Refreshing org.springframework.boot.context.embedded.AnnotationCo
nfigEmbeddedWebApplicationContext@27f8302d: startup date [Tue Mar 12 23:20:35 CS
T 2019]; root of context hierarchy
2019-03-12 23:20:35.837 [background-preinit] INFO org.hibernate.validator.inter
nal.util.Version - HV000001: Hibernate Validator 5.3.6.Final
2019-03-12 23:20:37.020 [MLog-Init-Reporter] INFO com.mchange.v2.log.MLog - MLo
g clients using slf4j logging.
2019-03-12 23:20:37.319 [main] INFO com.mchange.v2.c3p0.C3P0Registry - Initiali
zing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10
]
2019-03-12 23:20:38.632 [main] INFO o.s.b.c.e.tomcat.TomcatEmbeddedServletConta
iner - Tomcat initialized with port(s): 8080 (http)
2019-03-12 23:20:38.663 [main] INFO org.apache.coyote.http11.Http11NioProtocol

  • Initializing ProtocolHandler [“http-nio-8080”]
    2019-03-12 23:20:38.688 [main] INFO org.apache.catalina.core.StandardService -
    Starting service [Tomcat]
    2019-03-12 23:20:38.689 [main] INFO org.apache.catalina.core.StandardEngine - S
    tarting Servlet Engine: Apache Tomcat/8.5.37
    2019-03-12 23:20:39.459 [localhost-startStop-1] INFO o.a.c.c.ContainerBase.[Tom
    cat].[localhost].[/book] - Initializing Spring embedded WebApplicationContext
    2019-03-12 23:20:39.459 [localhost-startStop-1] INFO org.springframework.web.co
    ntext.ContextLoader - Root WebApplicationContext: initialization completed in 43
    79 ms
    2019-03-12 23:20:39.603 [localhost-startStop-1] INFO o.s.boot.web.servlet.Servl
    etRegistrationBean - Mapping servlet: ‘kaptchaServlet’ to [/Kaptcha]
    2019-03-12 23:20:39.607 [localhost-startStop-1] INFO o.s.boot.web.servlet.Servl
    etRegistrationBean - Mapping servlet: ‘dispatcherServlet’ to [/]
    2019-03-12 23:20:39.619 [localhost-startStop-1] INFO o.s.boot.web.servlet.Filte
    rRegistrationBean - Mapping filter: ‘characterEncodingFilter’ to: [/*]
    2019-03-12 23:20:40.058 [main] WARN o.s.b.c.e.AnnotationConfigEmbeddedWebApplic
    ationContext - Exception encountered during context initialization - cancelling
    refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyExceptio
    n: Error creating bean with name ‘areaServiceImpl’: Unsatisfied dependency expre
    ssed through field ‘areaDao’; nested exception is org.springframework.beans.fact
    ory.UnsatisfiedDependencyException: Error creating bean with name ‘areaDao’ defi
    ned in URL [jar:file:/D:/JAVA_EE/spring-boot/bookstore/target/book-0.0.1-SNAPSHO
    T.war!/WEB-INF/classes!/com/zhl/book/dao/AreaDao.class]: Unsatisfied dependency
    expressed through bean property ‘sqlSessionFactory’; nested exception is org.spr
    ingframework.beans.factory.BeanCreationException: Error creating bean with name
    ’sqlSessionFactory’ defined in class path resource [com/zhl/book/config/dao/Sess
    ionFactoryConfiguration.class]: Invocation of init method failed; nested excepti
    on is org.springframework.core.NestedIOException: Failed to parse mapping resour
    ce: ‘URL [jar:file:/D:/JAVA_EE/spring-boot/bookstore/target/book-0.0.1-SNAPSHOT.
    war!/WEB-INF/classes!/mapper/HeadLineDao.xml]’; nested exception is org.apache.i
    batis.builder.BuilderException: Error parsing Mapper XML. The XML location is ‘U
    RL [jar:file:/D:/JAVA_EE/spring-boot/bookstore/target/book-0.0.1-SNAPSHOT.war!/W
    EB-INF/classes!/mapper/HeadLineDao.xml]’. Cause: org.apache.ibatis.builder.Build
    erException: Error resolving class. Cause: org.apache.ibatis.type.TypeException:
    Could not resolve type alias ‘HeadLine’. Cause: java.lang.ClassNotFoundExcepti
    on: Cannot find class: HeadLine
    2019-03-12 23:20:40.063 [main] INFO org.apache.catalina.core.StandardService -
    Stopping service [Tomcat]
    2019-03-12 23:20:40.084 [main] INFO o.s.b.a.l.AutoConfigurationReportLoggingIni
    tializer -

Error starting ApplicationContext. To display the auto-configuration report re-r
un your application with ‘debug’ enabled.
2019-03-12 23:20:40.096 [main] ERROR org.springframework.boot.SpringApplication

  • Application startup failed
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating
    bean with name ‘areaServiceImpl’: Unsatisfied dependency expressed through fiel
    d ‘areaDao’; nested exception is org.springframework.beans.factory.UnsatisfiedDe
    pendencyException: Error creating bean with name ‘areaDao’ defined in URL [jar:f
    ile:/D:/JAVA_EE/spring-boot/bookstore/target/book-0.0.1-SNAPSHOT.war!/WEB-INF/cl
    asses!/com/zhl/book/dao/AreaDao.class]: Unsatisfied dependency expressed through
    bean property ‘sqlSessionFactory’; nested exception is org.springframework.bean
    s.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactor
    y’ defined in class path resource [com/zhl/book/config/dao/SessionFactoryConfigu
    ration.class]: Invocation of init method failed; nested exception is org.springf
    ramework.core.NestedIOException: Failed to parse mapping resource: ‘URL [jar:fil
    e:/D:/JAVA_EE/spring-boot/bookstore/target/book-0.0.1-SNAPSHOT.war!/WEB-INF/clas
    ses!/mapper/HeadLineDao.xml]’; nested exception is org.apache.ibatis.builder.Bui
    lderException: Error parsing Mapper XML. The XML location is ‘URL [jar:file:/D:/
    JAVA_EE/spring-boot/bookstore/target/book-0.0.1-SNAPSHOT.war!/WEB-INF/classes!/m
    apper/HeadLineDao.xml]’. Cause: org.apache.ibatis.builder.BuilderException: Erro
    r resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolv
    e type alias ‘HeadLine’. Cause: java.lang.ClassNotFoundException: Cannot find c
    lass: HeadLine
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanP
    ostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.j
    ava:586)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject
    (InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanP
    ostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java
    :364)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1269)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.createBean(AbstractAutowireCapableBeanFactory.java:481)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
    ject(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
    y.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
    an(AbstractBeanFactory.java:308)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
    (AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.
    preInstantiateSingletons(DefaultListableBeanFactory.java:761)
    at org.springframework.context.support.AbstractApplicationContext.finish
    BeanFactoryInitialization(AbstractApplicationContext.java:867)
    at org.springframework.context.support.AbstractApplicationContext.refres
    h(AbstractApplicationContext.java:543)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationConte
    xt.refresh(EmbeddedWebApplicationContext.java:124)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.
    java:693)
    at org.springframework.boot.SpringApplication.refreshContext(SpringAppli
    cation.java:360)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java
    :303)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java
    :1118)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java
    :1107)
    at com.zhl.book.BookstoreApplication.main(BookstoreApplication.java:10)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner
    .java:48)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
    at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59)

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Err
or creating bean with name ‘areaDao’ defined in URL [jar:file:/D:/JAVA_EE/spring
-boot/bookstore/target/book-0.0.1-SNAPSHOT.war!/WEB-INF/classes!/com/zhl/book/da
o/AreaDao.class]: Unsatisfied dependency expressed through bean property ‘sqlSes
sionFactory’; nested exception is org.springframework.beans.factory.BeanCreation
Exception: Error creating bean with name ‘sqlSessionFactory’ defined in class pa
th resource [com/zhl/book/config/dao/SessionFactoryConfiguration.class]: Invocat
ion of init method failed; nested exception is org.springframework.core.NestedIO
Exception: Failed to parse mapping resource: ‘URL [jar:file:/D:/JAVA_EE/spring-b
oot/bookstore/target/book-0.0.1-SNAPSHOT.war!/WEB-INF/classes!/mapper/HeadLineDa
o.xml]’; nested exception is org.apache.ibatis.builder.BuilderException: Error p
arsing Mapper XML. The XML location is ‘URL [jar:file:/D:/JAVA_EE/spring-boot/bo
okstore/target/book-0.0.1-SNAPSHOT.war!/WEB-INF/classes!/mapper/HeadLineDao.xml]
’. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cau
se: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘HeadLine
’. Cause: java.lang.ClassNotFoundException: Cannot find class: HeadLine
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.autowireByType(AbstractAutowireCapableBeanFactory.java:1362)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1254)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:481)
at org.springframework.beans.factory.support.AbstractBeanFactory1.getObject(AbstractBeanFactory.java:312)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)atorg.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1136)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064)atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor1.getOb ject(AbstractBeanFactory.java:312) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr y.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe an(AbstractBeanFactory.java:308) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:202) at org.springframework.beans.factory.config.DependencyDescriptor.resolve Candidate(DependencyDescriptor.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory. doResolveDependency(DefaultListableBeanFactory.java:1136) at org.springframework.beans.factory.support.DefaultListableBeanFactory. resolveDependency(DefaultListableBeanFactory.java:1064) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanP ostProcessor1.getObject(AbstractBeanFactory.java:312)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)atorg.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1136)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064)atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessorAutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.j
ava:583)
… 27 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name ‘sqlSessionFactory’ defined in class path resource [com/zhl/bo
ok/config/dao/SessionFactoryConfiguration.class]: Invocation of init method fail
ed; nested exception is org.springframework.core.NestedIOException: Failed to pa
rse mapping resource: ‘URL [jar:file:/D:/JAVA_EE/spring-boot/bookstore/target/bo
ok-0.0.1-SNAPSHOT.war!/WEB-INF/classes!/mapper/HeadLineDao.xml]’; nested excepti
on is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The
XML location is ‘URL [jar:file:/D:/JAVA_EE/spring-boot/bookstore/target/book-0.0
.1-SNAPSHOT.war!/WEB-INF/classes!/mapper/HeadLineDao.xml]’. Cause: org.apache.ib
atis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.t
ype.TypeException: Could not resolve type alias ‘HeadLine’. Cause: java.lang.Cl
assNotFoundException: Cannot find class: HeadLine
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1631)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:481)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolve
Candidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
doResolveDependency(DefaultListableBeanFactory.java:1136)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
resolveDependency(DefaultListableBeanFactory.java:1064)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.autowireByType(AbstractAutowireCapableBeanFactory.java:1347)
… 38 common frames omitted
Caused by: org.springframework.core.NestedIOException: Failed to parse mapping r
esource: ‘URL [jar:file:/D:/JAVA_EE/spring-boot/bookstore/target/book-0.0.1-SNAP
SHOT.war!/WEB-INF/classes!/mapper/HeadLineDao.xml]’; nested exception is org.apa
che.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location
is ‘URL [jar:file:/D:/JAVA_EE/spring-boot/bookstore/target/book-0.0.1-SNAPSHOT.w
ar!/WEB-INF/classes!/mapper/HeadLineDao.xml]’. Cause: org.apache.ibatis.builder.
BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeExcep
tion: Could not resolve type alias ‘HeadLine’. Cause: java.lang.ClassNotFoundEx
ception: Cannot find class: HeadLine
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSe
ssionFactoryBean.java:523)
at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessio
nFactoryBean.java:380)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1689)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1627)
… 48 common frames omitted
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML.
The XML location is ‘URL [jar:file:/D:/JAVA_EE/spring-boot/bookstore/target/boo
k-0.0.1-SNAPSHOT.war!/WEB-INF/classes!/mapper/HeadLineDao.xml]’. Cause: org.apac
he.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.iba
tis.type.TypeException: Could not resolve type alias ‘HeadLine’. Cause: java.la
ng.ClassNotFoundException: Cannot find class: HeadLine
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(X
MLMapperBuilder.java:120)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder
.java:92)
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSe
ssionFactoryBean.java:521)
… 51 common frames omitted
Caused by: org.apache.ibatis.builder.BuilderException: Error resolving class. Ca
use: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘HeadLin
e’. Cause: java.lang.ClassNotFoundException: Cannot find class: HeadLine
at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:1
18)
at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(
XMLStatementBuilder.java:74)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromCont
ext(XMLMapperBuilder.java:135)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromCont
ext(XMLMapperBuilder.java:128)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(X
MLMapperBuilder.java:118)
… 53 common frames omitted
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘H
eadLine’. Cause: java.lang.ClassNotFoundException: Cannot find class: HeadLine
at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegist
ry.java:120)
at org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:1
49)
at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:1
16)
… 57 common frames omitted
Caused by: java.lang.ClassNotFoundException: Cannot find class: HeadLine
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapp
er.java:200)
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapp
er.java:89)
图片是STS控制台的信息没报错页面可以正常显示,功能测试正常
图片描述

写回答

1回答

翔仔

2019-03-13

同学好,如果程序在STS运行没问题的话,需要严格按照视频项目的方式去打包,其他同学都正常呢,感觉是哪个地方没弄对,同学再把war解压出来看看里面是不是却了很多文件(跟视频里演示的那样,解压war看看),应该还是打包的方式有问题,但是这里信息不足没办法精确定位

0
3
哎呦喂啊哈
回复
zhldt
老哥,这个问题解决了嘛
2019-04-06
共3条回复

Java双版本(SSM到SpringBoot)校园商铺全栈开发

SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需

5113 学习 · 8144 问题

查看课程