Spring4.x第二章实例 1.0 chapter2【原书源码报错】

来源:互联网 发布:阿里云 连接 腾讯云 编辑:程序博客网 时间:2024/06/07 00:28
/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/bin/java -Dmaven.multiModuleProjectDirectory=/Volumes/我的电脑/我的电脑/Desktop/wangpan/chapter2 "-Dmaven.home=/Volumes/我的电脑/我的电脑/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3" "-Dclassworlds.conf=/Volumes/我的电脑/我的电脑/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin/m2.conf" -Dfile.encoding=UTF-8 -classpath "/Volumes/我的电脑/我的电脑/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/boot/plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2017.2.5 org.mortbay.jetty:maven-jetty-plugin:6.1.25:run-exploded
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Spring4.x第二章实例 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> maven-jetty-plugin:6.1.25:run-exploded (default-cli) > package @ chapter2 >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ chapter2 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ chapter2 ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ chapter2 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Volumes/我的电脑/我的电脑/Desktop/wangpan/chapter2/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ chapter2 ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ chapter2 ---
[INFO] Surefire report directory: /Volumes/我的电脑/我的电脑/Desktop/wangpan/chapter2/target/surefire-reports




-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.smart.service.UserServiceTest
Configuring TestNG with: TestNG652Configurator
Nov 23, 2017 4:20:47 PM org.springframework.test.context.support.DefaultTestContextBootstrapper getTestExecutionListeners
??: Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@544fe44c, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@31610302, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@71318ec4, org.springframework.test.context.support.DirtiesContextTestExecutionListener@21213b92, org.springframework.test.context.transaction.TransactionalTestExecutionListener@a67c67e, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@3327bd23]
Nov 23, 2017 4:20:47 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
??: Loading XML bean definitions from URL [file:/Volumes/我的电脑/我的电脑/Desktop/wangpan/chapter2/target/classes/smart-context.xml]
Nov 23, 2017 4:20:48 PM org.springframework.context.support.GenericApplicationContext prepareRefresh
??: Refreshing org.springframework.context.support.GenericApplicationContext@3c1f9361: startup date [Thu Nov 23 16:20:48 HKT 2017]; root of context hierarchy
Nov 23, 2017 4:20:49 PM org.springframework.test.context.transaction.TransactionContext startTransaction
??: Began transaction (1) for test context [DefaultTestContext@4c411a88 testClass = UserServiceTest, testInstance = com.smart.service.UserServiceTest@6e0e048a, testMethod = testFindUserByUserName@UserServiceTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@7b1a0cce testClass = UserServiceTest, locations = '{classpath*:/smart-context.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]]; transaction manager [org.springframework.jdbc.datasource.DataSourceTransactionManager@702c06fe]; rollback [true]
Nov 23, 2017 4:20:49 PM org.springframework.test.context.transaction.TransactionContext startTransaction
??: Began transaction (1) for test context [DefaultTestContext@4c411a88 testClass = UserServiceTest, testInstance = com.smart.service.UserServiceTest@6e0e048a, testMethod = testFindUserByUserName@UserServiceTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@7b1a0cce testClass = UserServiceTest, locations = '{classpath*:/smart-context.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]]; transaction manager [org.springframework.jdbc.datasource.DataSourceTransactionManager@702c06fe]; rollback [true]
Nov 23, 2017 4:20:49 PM org.springframework.test.context.transaction.TransactionContext startTransaction
??: Began transaction (1) for test context [DefaultTestContext@4c411a88 testClass = UserServiceTest, testInstance = com.smart.service.UserServiceTest@6e0e048a, testMethod = testFindUserByUserName@UserServiceTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@7b1a0cce testClass = UserServiceTest, locations = '{classpath*:/smart-context.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]]; transaction manager [org.springframework.jdbc.datasource.DataSourceTransactionManager@702c06fe]; rollback [true]
Nov 23, 2017 4:20:49 PM org.springframework.test.context.transaction.TransactionContext endTransaction
??: Rolled back transaction for test context [DefaultTestContext@4c411a88 testClass = UserServiceTest, testInstance = com.smart.service.UserServiceTest@6e0e048a, testMethod = testFindUserByUserName@UserServiceTest, testException = java.lang.AssertionError: expected [true] but found [false], mergedContextConfiguration = [MergedContextConfiguration@7b1a0cce testClass = UserServiceTest, locations = '{classpath*:/smart-context.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]].
Nov 23, 2017 4:20:49 PM org.springframework.test.context.transaction.TransactionContext endTransaction
??: Rolled back transaction for test context [DefaultTestContext@4c411a88 testClass = UserServiceTest, testInstance = com.smart.service.UserServiceTest@6e0e048a, testMethod = testFindUserByUserName@UserServiceTest, testException = java.lang.AssertionError: expected [true] but found [false], mergedContextConfiguration = [MergedContextConfiguration@7b1a0cce testClass = UserServiceTest, locations = '{classpath*:/smart-context.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]].
Nov 23, 2017 4:20:49 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
??: Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
Nov 23, 2017 4:20:49 PM org.springframework.jdbc.support.SQLErrorCodesFactory <init>
??: SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase, Hana]
Nov 23, 2017 4:20:49 PM org.springframework.test.context.transaction.TransactionContext endTransaction
??: Rolled back transaction for test context [DefaultTestContext@4c411a88 testClass = UserServiceTest, testInstance = com.smart.service.UserServiceTest@6e0e048a, testMethod = testAddLoginLog@UserServiceTest, testException = org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [INSERT INTO t_login_log(user_id,ip,login_datetime) VALUES(?,?,?)]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'ip' in 'field list', mergedContextConfiguration = [MergedContextConfiguration@7b1a0cce testClass = UserServiceTest, locations = '{classpath*:/smart-context.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]].
Nov 23, 2017 4:20:49 PM org.springframework.context.support.GenericApplicationContext doClose
??: Closing org.springframework.context.support.GenericApplicationContext@3c1f9361: startup date [Thu Nov 23 16:20:48 HKT 2017]; root of context hierarchy
Tests run: 3, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 1.963 sec <<< FAILURE! - in com.smart.service.UserServiceTest
testFindUserByUserName(com.smart.service.UserServiceTest)  Time elapsed: 0.11 sec  <<< FAILURE!
java.lang.AssertionError: expected [admin] but found [null]
at org.testng.Assert.fail(Assert.java:94)
at org.testng.Assert.failNotEquals(Assert.java:494)
at org.testng.Assert.assertEquals(Assert.java:123)
at org.testng.Assert.assertEquals(Assert.java:176)
at org.testng.Assert.assertEquals(Assert.java:186)
at com.smart.service.UserServiceTest.testFindUserByUserName(UserServiceTest.java:29)




testHasMatchUser(com.smart.service.UserServiceTest)  Time elapsed: 0.111 sec  <<< FAILURE!
java.lang.AssertionError: expected [true] but found [false]
at org.testng.Assert.fail(Assert.java:94)
at org.testng.Assert.failNotEquals(Assert.java:494)
at org.testng.Assert.assertTrue(Assert.java:42)
at org.testng.Assert.assertTrue(Assert.java:52)
at com.smart.service.UserServiceTest.testHasMatchUser(UserServiceTest.java:21)




testAddLoginLog(com.smart.service.UserServiceTest)  Time elapsed: 0.323 sec  <<< FAILURE!
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [INSERT INTO t_login_log(user_id,ip,login_datetime) VALUES(?,?,?)]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'ip' in 'field list'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2834)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2441)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2366)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2350)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:873)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:866)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:629)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:866)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:927)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:937)
at com.smart.dao.LoginLogDao.insertLoginLog(LoginLogDao.java:19)
at com.smart.service.UserService.loginSuccess(UserService.java:36)
at com.smart.service.UserService$$FastClassBySpringCGLIB$$753a64bf.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
at com.smart.service.UserService$$EnhancerBySpringCGLIB$$36adc704.loginSuccess(<generated>)
at com.smart.service.UserServiceTest.testAddLoginLog(UserServiceTest.java:42)








Results :




Failed tests: 
  UserServiceTest>AbstractTestNGSpringContextTests.run:175->testFindUserByUserName:29 expected [admin] but found [null]
  UserServiceTest>AbstractTestNGSpringContextTests.run:175->testHasMatchUser:21 expected [true] but found [false]
  UserServiceTest>AbstractTestNGSpringContextTests.run:175->testAddLoginLog:42 » BadSqlGrammar




Tests run: 3, Failures: 3, Errors: 0, Skipped: 0




[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.374 s
[INFO] Finished at: 2017-11-23T16:20:49+08:00
[INFO] Final Memory: 10M/232M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project chapter2: There are test failures.
[ERROR] 
[ERROR] Please refer to /Volumes/我的电脑/我的电脑/Desktop/wangpan/chapter2/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException




Process finished with exit code 1
原创粉丝点击