2016-10-25 75 views
0

我使用的Grails 3.1.1,我試圖配置我的應用程序,像這樣的JNDI連接..我在日誌中看到的,說Grails的3.1.1部署,JNDI連接

25-Oct-2016 11:41:03.764 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-8090] 25-Oct-2016 11:41:03.770 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-8009] 25-Oct-2016 11:41:03.771 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 36712 ms

Like this

因爲我使用Tomcat 8,讓我這樣的代碼

package accounter 

import grails.boot.GrailsApp 
import grails.boot.config.GrailsAutoConfiguration 
import javax.naming.NamingException; 
import javax.sql.DataSource; 
import org.springframework.context.annotation.Bean; 
import org.springframework.jndi.JndiObjectFactoryBean; 

class Application extends GrailsAutoConfiguration { 
    static void main(String[] args) { 
     GrailsApp.run(Application, args) 
    } 


    @Bean(destroyMethod="") 
    public DataSource jndiDataSource() throws IllegalArgumentException, NamingException { 
     JndiObjectFactoryBean bean = new JndiObjectFactoryBean(); 
     bean.setJndiName("java:comp/env/jdbc/akyDS"); 
     bean.setProxyInterface(DataSource.class); 
     bean.setLookupOnStartup(false); 
     bean.afterPropertiesSet(); 
     return (DataSource)bean.getObject(); 
    } 
} 

然後在context.xml

<?xml version="1.0" encoding="UTF-8"?> 

<!-- The contents of this file will be loaded for each web application --> 
<Context> 

    <!-- Default set of monitored resources. If one of these changes, the --> 
    <!-- web application will be reloaded.         --> 
    <WatchedResource>WEB-INF/web.xml</WatchedResource> 
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> 

    <Resource name="jdbc/akyDS" 
       auth="Container" 
       type="javax.sql.DataSource" 
       maxIdle="25" 
       minIdle="5" 
       initialSize="5" 
       validationQuery="SELECT 1" 
       timeBetweenEvictionRunsMillis="60000" 
       minEvictableIdleTimeMillis="60000" 
       username="root" 
       password="root" 
       driverClassName="com.mysql.jdbc.Driver" 
       url="jdbc:mysql://localhost:3306/accounter?autoReconnect=true" 
    /> 

    <!-- Uncomment this to disable session persistence across Tomcat restarts --> 
    <!-- 
    <Manager pathname="" /> 
    --> 
</Context> 

但是當我嘗試運行我的tomcat,我得到一個日誌這樣的..

catalina log

,但我看不到我的項目是成功的,當我進入到啓動localhost:8090/

設置等級日誌時出現此錯誤DEBUG

initialSize=5; maxWait=10000; testOnBorrow=true; testOnReturn=false; timeBetwee 
nEvictionRunsMillis=5000; numTestsPerEvictionRun=0; minEvictableIdleTimeMillis=6 
0000; testWhileIdle=true; testOnConnect=false; password=********; url=jdbc:mysql 
://localhost:3306/accounter?autoReconnect=true&useUnicode=true&characterEncoding 
=UTF-8; username=root; validationQuery=SELECT 1; validationQueryTimeout=3; valid 
atorClassName=null; validationInterval=15000; accessToUnderlyingConnectionAllowe 
d=true; removeAbandoned=false; removeAbandonedTimeout=60; logAbandoned=false; co 
nnectionProperties=null; initSQL=null; jdbcInterceptors=ConnectionState; jmxEnab 
led=true; fairQueue=true; useEquals=true; abandonWhenPercentageFull=0; maxAge=60 
0000; useLock=false; dataSource=null; dataSourceJNDI=null; suspectTimeout=0; alt 
ernateUsernameAllowed=false; commitOnReturn=false; rollbackOnReturn=false; useDi 
sposableConnectionFacade=true; logValidationErrors=false; propagateInterruptStat 
e=false; ignoreExceptionOnPreLoad=false; }]] 
DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Releasi 
ng JDBC Connection [Lazy Connection proxy for target DataSource [org.apache.tomc 
[email protected]{ConnectionPool[defaultAutoCommit=null; defaultR 
eadOnly=false; defaultTransactionIsolation=2; defaultCatalog=null; driverClassNa 
me=com.mysql.jdbc.Driver; maxActive=50; maxIdle=25; minIdle=5; initialSize=5; ma 
xWait=10000; testOnBorrow=true; testOnReturn=false; timeBetweenEvictionRunsMilli 
s=5000; numTestsPerEvictionRun=0; minEvictableIdleTimeMillis=60000; testWhileIdl 
e=true; testOnConnect=false; password=********; url=jdbc:mysql://localhost:3306/ 
accounter?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8; username=r 
oot; validationQuery=SELECT 1; validationQueryTimeout=3; validatorClassName=null 
; validationInterval=15000; accessToUnderlyingConnectionAllowed=true; removeAban 
doned=false; removeAbandonedTimeout=60; logAbandoned=false; connectionProperties 
=null; initSQL=null; jdbcInterceptors=ConnectionState; jmxEnabled=true; fairQueu 
e=true; useEquals=true; abandonWhenPercentageFull=0; maxAge=600000; useLock=fals 
e; dataSource=null; dataSourceJNDI=null; suspectTimeout=0; alternateUsernameAllo 
wed=false; commitOnReturn=false; rollbackOnReturn=false; useDisposableConnection 
Facade=true; logValidationErrors=false; propagateInterruptState=false; ignoreExc 
eptionOnPreLoad=false; }]] after transaction 
DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Returning JDBC Conne 
ction to DataSource 

我得到一些錯誤,刪除此代碼application.yml

dataSource: 
    jndiName: java:comp/env/akyDS 
# pooled: true 
# jmxExport: true 
# driverClassName: com.mysql.jdbc.Driver 
# username: dddd 
# password: [email protected] 
#  username: ddddg 
#  password: [email protected] 


#dataSource: 
#  pooled: true 
#  jmxExport: true 
#  driverClassName: "oracle.jdbc.OracleDriver" 
#  dialect: org.hibernate.dialect.Oracle10gDialect 
#  username: "accounter" 
#  password: "root" 

environments: 
    development: 
     dataSource: 
      dbCreate: update 
#   url: jdbc:oracle:thin:@localhost:1521:xe 
      url: jdbc:mysql://localhost:3306/accounter?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8 

    test: 
     dataSource: 
      dbCreate: update 
#   url: jdbc:oracle:thin:@localhost:1521:accounter 
      url: jdbc:mysql://localhost:3306/accounter?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8 
    production: 
     dataSource: 
      dbCreate: update 
#   url: jdbc:oracle:thin:@localhost:1521:accounter 
#   jndiName: java:comp/env/akyDS 
      url: jdbc:mysql://localhost:3306/accounter?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8 
      properties: 
       jmxEnabled: true 
       initialSize: 5 
       maxActive: 50 
       minIdle: 5 
       maxIdle: 25 
       maxWait: 10000 
       maxAge: 600000 
       timeBetweenEvictionRunsMillis: 5000 
       minEvictableIdleTimeMillis: 60000 
       validationQuery: SELECT 1 
       validationQueryTimeout: 3 
       validationInterval: 15000 
       testOnBorrow: true 
       testWhileIdle: true 
       testOnReturn: false 
       jdbcInterceptors: ConnectionState 
       defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED 

與刪除此代碼後,然後我運行grails prod war之後,我再次嘗試部署。

我得到這個錯誤..

.java:724) [catalina.jar:8.5.6] 
     at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:70 
0) [catalina.jar:8.5.6] 
     at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) 
[catalina.jar:8.5.6] 
     at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952) 
[catalina.jar:8.5.6] 
     at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java: 
1823) [catalina.jar:8.5.6] 
     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:51 
1) [na:1.8.0_101] 
     at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_10 
1] 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor. 
java:1142) [na:1.8.0_101] 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor 
.java:617) [na:1.8.0_101] 
     at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101] 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati 
ng bean with name 'transactionManager' defined in class path resource [org/sprin 
gframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfiguration 
.class]: Bean instantiation via factory method failed; nested exception is org.s 
pringframework.beans.BeanInstantiationException: Failed to instantiate [org.spri 
ngframework.jdbc.datasource.DataSourceTransactionManager]: Factory method 'trans 
actionManager' threw exception; nested exception is java.lang.IllegalArgumentExc 
eption: Property 'dataSource' is required 
     at org.springframework.beans.factory.support.ConstructorResolver.instant 
iateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.2.4.RELEAS 
E.jar:4.2.4.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:11 
23) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) ~[sprin 
g-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans 
-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4 
.2.4.RELEASE.jar:4.2.4.RELEASE] 
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb 
ject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEAS 
E] 
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr 
y.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.4.RELEA 
SE.jar:4.2.4.RELEASE] 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe 
an(AbstractBeanFactory.java:302) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 

     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean 
(AbstractBeanFactory.java:202) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
     at org.grails.transaction.TransactionManagerPostProcessor.initialize(Tra 
nsactionManagerPostProcessor.java:75) ~[grails-core-3.1.1.jar:3.1.1] 
     at org.grails.transaction.TransactionManagerPostProcessor.setBeanFactory 
(TransactionManagerPostProcessor.java:53) ~[grails-core-3.1.1.jar:3.1.1] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1597) ~[sprin 
g-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1565) ~[spring-be 
ans-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans 
-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
     ... 29 common frames omitted 
Caused by: org.springframework.beans.BeanInstantiationException: Failed to insta 
ntiate [org.springframework.jdbc.datasource.DataSourceTransactionManager]: Facto 
ry method 'transactionManager' threw exception; nested exception is java.lang.Il 
legalArgumentException: Property 'dataSource' is required 
     at org.springframework.beans.factory.support.SimpleInstantiationStrategy 
.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.2.4.RELEASE. 
jar:4.2.4.RELEASE] 
     at org.springframework.beans.factory.support.ConstructorResolver.instant 
iateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.2.4.RELEAS 
E.jar:4.2.4.RELEASE] 
     ... 42 common frames omitted 
Caused by: java.lang.IllegalArgumentException: Property 'dataSource' is required 

     at org.springframework.jdbc.datasource.DataSourceTransactionManager.afte 
rPropertiesSet(DataSourceTransactionManager.java:167) ~[spring-jdbc-4.2.4.RELEAS 
E.jar:4.2.4.RELEASE] 
     at org.springframework.jdbc.datasource.DataSourceTransactionManager.<ini 
t>(DataSourceTransactionManager.java:124) ~[spring-jdbc-4.2.4.RELEASE.jar:4.2.4. 
RELEASE] 
     at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana 
gerAutoConfiguration.transactionManager(DataSourceTransactionManagerAutoConfigur 
ation.java:56) ~[spring-boot-autoconfigure-1.3.2.RELEASE.jar:1.3.2.RELEASE] 
     at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana 
gerAutoConfiguration$$EnhancerBySpringCGLIB$$ec1411b5.CGLIB$transactionManager$0 
(<generated>) ~[spring-boot-autoconfigure-1.3.2.RELEASE.jar:1.3.2.RELEASE] 
     at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana 
gerAutoConfiguration$$EnhancerBySpringCGLIB$$ec1411b5$$FastClassBySpringCGLIB$$6 
2dee341.invoke(<generated>) ~[spring-boot-autoconfigure-1.3.2.RELEASE.jar:1.3.2. 
RELEASE] 
     at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.j 
ava:228) ~[spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
     at org.springframework.context.annotation.ConfigurationClassEnhancer$Bea 
nMethodInterceptor.intercept(ConfigurationClassEnhancer.java:355) ~[spring-conte 
xt-4.2.4.RELEASE.jar:4.2.4.RELEASE] 
     at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana 
gerAutoConfiguration$$EnhancerBySpringCGLIB$$ec1411b5.transactionManager(<genera 
ted>) ~[spring-boot-autoconfigure-1.3.2.RELEASE.jar:1.3.2.RELEASE] 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8. 
0_101] 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. 
java:62) ~[na:1.8.0_101] 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces 
sorImpl.java:43) ~[na:1.8.0_101] 
     at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101] 
     at org.springframework.beans.factory.support.SimpleInstantiationStrategy 
.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.2.4.RELEASE. 
jar:4.2.4.RELEASE] 
     ... 43 common frames omitted 
26-Oct-2016 16:35:15.533 SEVERE [localhost-startStop-1] org.apache.catalina.core 
.ContainerBase.addChildInternal ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngi 
ne[Catalina].StandardHost[localhost].StandardContext[]] 
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) 
     at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase 
.java:724) 
     at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:70 
0) 
     at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) 

     at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952) 

     at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java: 
1823) 
     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:51 
1) 
     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 creati 
ng bean with name 'transactionManagerPostProcessor': Initialization of bean fail 
ed; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'transactionManager' defined in class path resour 
ce [org/springframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAuto 
Configuration.class]: Bean instantiation via factory method failed; nested excep 
tion is org.springframework.beans.BeanInstantiationException: Failed to instanti 
ate [org.springframework.jdbc.datasource.DataSourceTransactionManager]: Factory 
method 'transactionManager' threw exception; nested exception is java.lang.Illeg 
alArgumentException: Property 'dataSource' is required 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb 
ject(AbstractBeanFactory.java:306) 
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr 
y.getSingleton(DefaultSingletonBeanRegistry.java:230) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe 
an(AbstractBeanFactory.java:302) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean 
(AbstractBeanFactory.java:202) 
     at org.springframework.context.support.PostProcessorRegistrationDelegate 
.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:207) 
     at org.springframework.context.support.AbstractApplicationContext.regist 
erBeanPostProcessors(AbstractApplicationContext.java:687) 
     at org.springframework.context.support.AbstractApplicationContext.refres 
h(AbstractApplicationContext.java:523) 
     at org.springframework.boot.context.embedded.EmbeddedWebApplicationConte 
xt.refresh(EmbeddedWebApplicationContext.java:118) 
     at org.springframework.boot.SpringApplication.refresh(SpringApplication. 
java:766) 
     at org.springframework.boot.SpringApplication.createAndRefreshContext(Sp 
ringApplication.java:361) 
     at org.springframework.boot.SpringApplication.run(SpringApplication.java 
:307) 
     at grails.boot.GrailsApp.run(GrailsApp.groovy:55) 
     at org.springframework.boot.context.web.SpringBootServletInitializer.run 
(SpringBootServletInitializer.java:149) 
     at org.grails.boot.context.web.GrailsAppServletInitializer.createRootApp 
licationContext(GrailsAppServletInitializer.groovy:57) 
     at org.springframework.boot.context.web.SpringBootServletInitializer.onS 
tartup(SpringBootServletInitializer.java:85) 
     at org.springframework.web.SpringServletContainerInitializer.onStartup(S 
pringServletContainerInitializer.java:175) 
     at org.apache.catalina.core.StandardContext.startInternal(StandardContex 
t.java:5178) 
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
     ... 10 more 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati 
ng bean with name 'transactionManager' defined in class path resource [org/sprin 
gframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfiguration 
.class]: Bean instantiation via factory method failed; nested exception is org.s 
pringframework.beans.BeanInstantiationException: Failed to instantiate [org.spri 
ngframework.jdbc.datasource.DataSourceTransactionManager]: Factory method 'trans 
actionManager' threw exception; nested exception is java.lang.IllegalArgumentExc 
eption: Property 'dataSource' is required 
     at org.springframework.beans.factory.support.ConstructorResolver.instant 
iateUsingFactoryMethod(ConstructorResolver.java:599) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:11 
23) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb 
ject(AbstractBeanFactory.java:306) 
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr 
y.getSingleton(DefaultSingletonBeanRegistry.java:230) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe 
an(AbstractBeanFactory.java:302) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean 
(AbstractBeanFactory.java:202) 
     at org.grails.transaction.TransactionManagerPostProcessor.initialize(Tra 
nsactionManagerPostProcessor.java:75) 
     at org.grails.transaction.TransactionManagerPostProcessor.setBeanFactory 
(TransactionManagerPostProcessor.java:53) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1597) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1565) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) 
     ... 29 more 
Caused by: org.springframework.beans.BeanInstantiationException: Failed to insta 
ntiate [org.springframework.jdbc.datasource.DataSourceTransactionManager]: Facto 
ry method 'transactionManager' threw exception; nested exception is java.lang.Il 
legalArgumentException: Property 'dataSource' is required 
     at org.springframework.beans.factory.support.SimpleInstantiationStrategy 
.instantiate(SimpleInstantiationStrategy.java:189) 
     at org.springframework.beans.factory.support.ConstructorResolver.instant 
iateUsingFactoryMethod(ConstructorResolver.java:588) 
     ... 42 more 
Caused by: java.lang.IllegalArgumentException: Property 'dataSource' is required 

     at org.springframework.jdbc.datasource.DataSourceTransactionManager.afte 
rPropertiesSet(DataSourceTransactionManager.java:167) 
     at org.springframework.jdbc.datasource.DataSourceTransactionManager.<ini 
t>(DataSourceTransactionManager.java:124) 
     at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana 
gerAutoConfiguration.transactionManager(DataSourceTransactionManagerAutoConfigur 
ation.java:56) 
     at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana 
gerAutoConfiguration$$EnhancerBySpringCGLIB$$ec1411b5.CGLIB$transactionManager$0 
(<generated>) 
     at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana 
gerAutoConfiguration$$EnhancerBySpringCGLIB$$ec1411b5$$FastClassBySpringCGLIB$$6 
2dee341.invoke(<generated>) 
     at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.j 
ava:228) 
     at org.springframework.context.annotation.ConfigurationClassEnhancer$Bea 
nMethodInterceptor.intercept(ConfigurationClassEnhancer.java:355) 
     at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana 
gerAutoConfiguration$$EnhancerBySpringCGLIB$$ec1411b5.transactionManager(<genera 
ted>) 
     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.beans.factory.support.SimpleInstantiationStrategy 
.instantiate(SimpleInstantiationStrategy.java:162) 
     ... 43 more 

26-Oct-2016 16:35:15.535 SEVERE [localhost-startStop-1] org.apache.catalina.star 
tup.HostConfig.deployWAR Error deploying web application archive C:\apache-tomca 
t-8.5.6\webapps\ROOT.war 
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.cata 
lina.LifecycleException: Failed to start component [StandardEngine[Catalina].Sta 
ndardHost[localhost].StandardContext[]] 
     at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase 
.java:728) 
     at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:70 
0) 
     at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) 

     at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952) 

     at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java: 
1823) 
     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:51 
1) 
     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) 

26-Oct-2016 16:35:15.537 INFO [localhost-startStop-1] org.apache.catalina.startu 
p.HostConfig.deployWAR Deployment of web application archive C:\apache-tomcat-8. 
5.6\webapps\ROOT.war has finished in 48,325 ms 
26-Oct-2016 16:35:15.539 INFO [main] org.apache.coyote.AbstractProtocol.start St 
arting ProtocolHandler [http-nio-8090] 
26-Oct-2016 16:35:15.547 INFO [main] org.apache.coyote.AbstractProtocol.start St 
arting ProtocolHandler [ajp-nio-8009] 
26-Oct-2016 16:35:15.548 INFO [main] org.apache.catalina.startup.Catalina.start 
Server startup in 48378 ms 

回答

0

頂部的三個日誌報表什麼都沒有做這個,並且是信息報表,而不是錯誤。

你展示的其它輸出同樣不是一個錯誤,這是告訴你(連同一堆的配置設置),它已完成了一些MySQL連接,並把他們送回連接池,這是正是什麼你想看看什麼時候使用連接池。它顯示數據庫的URL爲jdbc:mysql://localhost:3306/accounter?autoReconnect=true,這是您從context.xml中配置的數據源顯示的內容。

省略所有的連接細節它基本上是說這裏

Releasing JDBC Connection ... after transaction 
Returning JDBC Connection to DataSource 

沒有證據表明爲什麼您可能無法從瀏覽器訪問您的應用程序,但據數據庫連接而言,一切看起來還不錯。

+0

但是它運行良好,當我從'jndi到jdbc上更改'application.yml'的連接時 – akiong

+0

當然,但沒有任何實際的錯誤消息或其他有用的信息沒有太多的工作與 –

+0

我試圖部署戰爭文件到其他服務器,但我仍然無法從瀏覽器訪問應用程序 – akiong