Exception in thread "Thread-11" java.lang.AbstractMethodError

java rmi在调用服务端方法,个别的方法调用不了,报下面的错误,有的方法可以正常调用到。。请教一下原因。Exception in thread "Thread-11" java.lang.AbstractMethodError: com.hit.www.rmi.sms.SmsRmiMgrImpl_Stub.poolToFail(Ljava/lang/String;)Ljava/lang/String; at com.hit.www.application.smsv3.panel.SendSmsPoolPanel$ToFailProgressDlg$1.construct(SendSmsPoolPanel.java:1592) at com.hit.www.framework.ui.SwingWorker$2.run(SwingWorker.java:48) at java.lang.Thread.run(Thread.java:722)

rmi

1个回答

接口米有实例化。也有可能是没有注入。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Exception in thread "Thread-12" java.lang.RuntimeException: java.lang.NullPointerException
第一次着手项目,springboot+mybatis,项目搭建是跟着教程做的。项目搭建好之后项目能正常运行,但是启动后报: Exception in thread "Thread-12" java.lang.RuntimeException: java.lang.NullPointerException at com.mysql.jdbc.JDBC4Connection$1$1.run(JDBC4Connection.java:106) Caused by: java.lang.NullPointerException at com.mysql.jdbc.ConnectionImpl.abortInternal(ConnectionImpl.java:1240) at com.mysql.jdbc.JDBC4Connection$1$1.run(JDBC4Connection.java:104) 启动Console: 2019-08-05 10:29:12.921 INFO 7416 --- [ restartedMain] com.xintujiuzhang.aimanagement.App : Starting App on DESKTOP-J57CTN6 with PID 7416 (D:\JAVA\eclipse\TaxHandwritingRecognition\target\classes started by Administrator in D:\JAVA\eclipse\TaxHandwritingRecognition) 2019-08-05 10:29:12.921 INFO 7416 --- [ restartedMain] com.xintujiuzhang.aimanagement.App : No active profile set, falling back to default profiles: default 2019-08-05 10:29:12.958 INFO 7416 --- [ restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6070b0bb: startup date [Mon Aug 05 10:29:12 CST 2019]; root of context hierarchy 2019-08-05 10:29:13.450 INFO 7416 --- [ restartedMain] o.s.b.f.xml.XmlBeanDefinitionReader : Loading XML bean definitions from class path resource [mybatis-config.xml] 2019-08-05 10:29:13.503 INFO 7416 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'sqlSessionFactory' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=app; factoryMethodName=sqlSessionFactoryBean; initMethodName=null; destroyMethodName=(inferred); defined in com.xintujiuzhang.aimanagement.App] with [Generic bean: class [org.mybatis.spring.SqlSessionFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [mybatis-config.xml]] 2019-08-05 10:29:13.599 WARN 7416 --- [ restartedMain] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.xintujiuzhang.aimanagement]' package. Please check your configuration. 2019-08-05 10:29:13.958 INFO 7416 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$b535b905] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-08-05 10:29:14.332 INFO 7416 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2019-08-05 10:29:14.348 INFO 7416 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2019-08-05 10:29:14.349 INFO 7416 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.28 2019-08-05 10:29:14.355 INFO 7416 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : Loaded APR based Apache Tomcat Native library [1.2.21] using APR version [1.6.5]. 2019-08-05 10:29:14.355 INFO 7416 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true]. 2019-08-05 10:29:14.355 INFO 7416 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true] 2019-08-05 10:29:14.357 INFO 7416 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : OpenSSL successfully initialized [OpenSSL 1.1.1a 20 Nov 2018] 2019-08-05 10:29:14.418 INFO 7416 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2019-08-05 10:29:14.418 INFO 7416 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1462 ms 2019-08-05 10:29:14.514 INFO 7416 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/] 2019-08-05 10:29:14.517 INFO 7416 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2019-08-05 10:29:14.517 INFO 7416 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2019-08-05 10:29:14.517 INFO 7416 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2019-08-05 10:29:14.517 INFO 7416 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2019-08-05 10:29:14.631 INFO 7416 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2019-08-05 10:29:19.625 INFO 7416 --- [ restartedMain] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Driver does not support get/set network timeout for connections. (com.mysql.jdbc.JDBC4Connection.getNetworkTimeout()I) 2019-08-05 10:29:19.629 INFO 7416 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2019-08-05 10:29:19.670 INFO 7416 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2019-08-05 10:29:19.684 INFO 7416 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2019-08-05 10:29:19.738 INFO 7416 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.2.10.Final} 2019-08-05 10:29:19.739 INFO 7416 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2019-08-05 10:29:19.770 INFO 7416 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 2019-08-05 10:29:19.874 INFO 7416 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect 2019-08-05 10:29:19.897 INFO 7416 --- [ restartedMain] o.h.e.j.e.i.LobCreatorBuilderImpl : HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4 2019-08-05 10:29:20.037 INFO 7416 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 10:29:20,543 INFO App:32-org.springframework.orm.jpa.JpaTransactionManager 2019-08-05 10:29:20.796 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6070b0bb: startup date [Mon Aug 05 10:29:12 CST 2019]; root of context hierarchy 2019-08-05 10:29:20.824 WARN 7416 --- [ restartedMain] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning 2019-08-05 10:29:20.846 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/application/handwriting_authorization],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.ApplicationAuthorizationController.joinHWA(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.847 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/application/handwriting_information],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.ApplicationInformationController.joinHWI(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.847 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/log/background_management_login],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.BackgroundManagementLoginController.joinHWI(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.847 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/log/computer_login],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.ComputerLoginController.jumpDEM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.847 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/department_management],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.DepartmentManagementController.jumpDEM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.848 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/dictionary_management],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.DictionaryManagementController.jumpDM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.848 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/equipment/hardware_devices],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.EquipmentManagementController.jumpDM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.848 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/queryGetServerStatusInterface],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.xintujiuzhang.aimanagement.controller.GetServerStatusInterfaceController.queryGetServerStatus(java.lang.String,java.lang.String) 2019-08-05 10:29:20.848 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/queryHandwritingInterface],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.xintujiuzhang.aimanagement.controller.HandwritingInterfaceController.queryHandwriting(java.lang.String,java.lang.String,java.lang.Integer,java.util.Date) 2019-08-05 10:29:20.849 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/identity/identity_management],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.IdentityManagementController.jumpDM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.849 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/queryInstallationRequest],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.xintujiuzhang.aimanagement.controller.InstallationRequestInterfaceController.queryInstallationRequest(java.lang.String,java.lang.String,java.lang.String) 2019-08-05 10:29:20.849 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/queryLicenseInterface],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.xintujiuzhang.aimanagement.controller.LicenseInterfaceController.queryLicense(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.Date) 2019-08-05 10:29:20.851 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.MainController.main(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.851 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/login],methods=[GET]}" onto public org.springframework.web.servlet.ModelAndView com.xintujiuzhang.aimanagement.controller.MainController.login() 2019-08-05 10:29:20.851 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/login],methods=[POST]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.MainController.login(java.lang.String,java.lang.String,java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.851 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/main],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.MainController.jumpmain(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.852 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/menu_management],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.MenuManagementController.jumpMM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.852 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/log/module_browsing],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.ModuleBrowsingController.jumpTM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.852 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/log/module_operation],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.ModuleOperationController.jumpMM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.852 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/deletehandwriting],methods=[POST]}" onto public void com.xintujiuzhang.aimanagement.controller.NotesController.deletehandwriting(java.lang.String) 2019-08-05 10:29:20.852 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/updatehandwriting],methods=[POST]}" onto public void com.xintujiuzhang.aimanagement.controller.NotesController.updatehandwriting(com.xintujiuzhang.aimanagement.pojo.Handwriting) 2019-08-05 10:29:20.852 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/addhandwriting],methods=[POST]}" onto public void com.xintujiuzhang.aimanagement.controller.NotesController.addhandwriting(com.xintujiuzhang.aimanagement.pojo.Handwriting) 2019-08-05 10:29:20.853 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/querynotes],methods=[GET]}" onto public com.xintujiuzhang.aimanagement.pojo.Handwriting com.xintujiuzhang.aimanagement.controller.NotesController.querynotes(java.lang.String) 2019-08-05 10:29:20.853 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/parameter_settings],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.parameterSettingsController.jumpPS(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.853 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/role_authorization],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.RoleAuthorizationController.jumpRA(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.853 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/log/service_call],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.ServiceCallController.jumpRA(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.853 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/task_management],methods=[GET]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.TaskManagementController.jumpTM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.854 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/user_management]}" onto public java.lang.String com.xintujiuzhang.aimanagement.controller.UserController.jnmpUM(java.util.Map<java.lang.String, java.lang.Object>) 2019-08-05 10:29:20.854 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/queryUserInterface],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.xintujiuzhang.aimanagement.controller.UserInterfaceController.queryLicense(java.lang.String,java.lang.String,java.lang.Integer,java.util.Date) 2019-08-05 10:29:20.854 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/queryVersionCheckingInterface],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.xintujiuzhang.aimanagement.controller.VersionCheckingInterfaceController.queryVersionChecking(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.Integer,java.util.Date) 2019-08-05 10:29:20.854 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/queryVersionupdateInterface],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.xintujiuzhang.aimanagement.controller.VersionUpdateInterfaceController.queryVersionupdate(java.lang.String,java.lang.String,java.lang.String,java.util.Date) 2019-08-05 10:29:20.857 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest) 2019-08-05 10:29:20.857 INFO 7416 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) 2019-08-05 10:29:20.881 INFO 7416 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2019-08-05 10:29:20.881 INFO 7416 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2019-08-05 10:29:20.906 INFO 7416 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2019-08-05 10:29:21.115 INFO 7416 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729 2019-08-05 10:29:21.164 INFO 7416 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 2019-08-05 10:29:21.165 INFO 7416 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure 2019-08-05 10:29:21.170 INFO 7416 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource] 2019-08-05 10:29:21.196 INFO 7416 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2019-08-05 10:29:21.198 INFO 7416 --- [ restartedMain] com.xintujiuzhang.aimanagement.App : Started App in 8.458 seconds (JVM running for 8.828) Exception in thread "Thread-12" java.lang.RuntimeException: java.lang.NullPointerException at com.mysql.jdbc.JDBC4Connection$1$1.run(JDBC4Connection.java:106) Caused by: java.lang.NullPointerException at com.mysql.jdbc.ConnectionImpl.abortInternal(ConnectionImpl.java:1240) at com.mysql.jdbc.JDBC4Connection$1$1.run(JDBC4Connection.java:104) **在执行一些方法后“Thread-12”会不断增加** **ps:“Thread-668"**
hibernate连接oracle报错
Exception in thread "main" java.lang.AbstractMethodError: Method oracle/jdbc/driver/OracleDatabaseMetaData.supportsNamedParameters()Z is abstract
org.springframework.beans.factory.BeanCreationException 异常
``` HTTP Status 500 - Servlet.init() for servlet viewspace threw exception type Exception report message Servlet.init() for servlet viewspace threw exception description The server encountered an internal error that prevented it from fulfilling this request. exception javax.servlet.ServletException: Servlet.init() for servlet viewspace threw exception org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:495) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:767) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1347) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Unknown Source) root cause org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/viewspace-servlet.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is defined org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1481) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:776) org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) javax.servlet.GenericServlet.init(GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:495) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:767) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1347) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Unknown Source) root cause org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is defined org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:702) org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1180) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1481) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:776) org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) javax.servlet.GenericServlet.init(GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:495) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:767) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1347) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Unknown Source) note The full stack trace of the root cause is available in the Apache Tomcat/9.0.0.M17 logs. ``` ``` 这是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" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- 自动扫描组件 --> <context:component-scan base-package="org.alex.samples"/> <!-- 打开注解驱动 --> <mvc:annotation-driven/> <!-- 配置jsp视图解析器 ,需要有jstl这个jar包,否则不能映射--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/view/"/> <property name="suffix" value=".jsp"/> </bean> <!-- 国际化 --> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basenames" value="i18n.message"></property> <property name="useCodeAsDefaultMessage" value="true" /> <property name="defaultEncoding" value="UTF-8"/> </bean> <!-- 基于Session的国际化配置--> <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"></bean> <!-- 动态语言切换 --> <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"> <property name="paramName" value="locale"></property> </bean> <!-- 静态资源访问 --> <mvc:resources location="/static/lib/" mapping="/static/lib/**" /> <mvc:resources location="/static/assets/" mapping="/static/assets/**" /> <mvc:resources location="/static/docs/" mapping="/static/docs/**" /> <!-- JSR 303 Validator --> <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"> <property name="providerClass" value="org.hibernate.validator.HibernateValidator"></property> <property name="validationMessageSource" ref="messageSource"/> </bean> <!-- 数据库配置连接池 --> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <!-- MySQL数据库配置--> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf-8"/> <property name="username" value="root"/> <property name="password" value="123456"/> </bean> <!-- hibernate --> <bean id="SessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="packagesToScan" value="org.alex.samples"/> <property name="hibernateProperties"> <props> <prop key="dialect">org.hibernate.dialect.MySQL5Dialect</prop> <prop key="show_sql">true</prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="false" /> <!-- 配置jdbcTemplate --> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" abstract="false" lazy-init="false" autowire="default"> <property name="dataSource"> <ref bean="dataSource"/> </property> </bean> <bean id="UserDAOImpl" class="org.alex.samples.dao.UserDAOImpl"> <property name="jdbcTemplate"> <ref bean="jdbcTemplate" /> </property> </bean> <bean id="SubDAOImpl" class="org.alex.samples.dao.SubDAOImpl"> <property name="jdbcTemplate"> <ref bean="jdbcTemplate" /> </property> </bean> </beans> ```
hibernate 日志异常
最近学习hibernate,看书感觉可以,实际操作怎么就那么难呢! 我用的是:hibernate3.2 eclipse3.3 (没有Myeclipse插件) Mysql6.0 一:main()函数 package org.first; import org.hibernate.*; import org.hibernate.cfg.*; public abstract class FirstM { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Configuration conf=new Configuration().configure(); SessionFactory sf=conf.buildSessionFactory(); Session sess=sf.openSession(); Transaction tx=sess.beginTransaction(); FirstBean fb=new FirstBean(); fb.setUserId(12); fb.setUserName("thmei123"); sess.save(fb); tx.commit(); sess.close(); } } 二:持久化类:很简单,一个主键userId,和一个属性userName; public class FirstBean { private int userId; private String userName; public void setUserId(int userId) { this.userId=userId; } public int getUserid() { return this.userId; } public void setUserName(String userName) { this.userName=userName; } public String getUserName() { return this.userName; } } 三:影射文件和配置文件: 1:<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="FirstBean" table="student"> <id name="userId" unsaved-value="null"> <generator class="identity"/> </id> <property name="userName"/> </class> </hibernate-mapping> 2: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property> <property name="hibernate.connection.password">thmei123</property> <property name="hibernate.connection.url">jdbc:mysql://localhost/user</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.c3p0.max_size">20</property> <property name="hibernate.c3p0.min_size">1</property> <property name="hibernate.c3p0.timeout">5000</property> <property name="hibernate.c3p0.max_statements">100</property> <property name="hibernate.c3p0.idle_test_period">3000</property> <property name="hibernate.c3p0.acquire_increment">2</property> <property name="hibernate.c3p0.validate">true</property> <mapping resource="hib.hbm.xml"> </session-factory> </hibernate-configuration> 说明;在主函数main()中运行后提示: Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException at org.first.FirstM.main(FirstM.java:12) Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) 提示的是要文件: log4j-1.2.11.jar 和commons-logging-1.0.4.jar 这两个jar文件我都拷贝到了SRC下面了,也不可以阿 在网上查询说的是好像main()函数中不可以用日志文件, 希望大家帮我了, 另外 请大家给我一个详细的例子吧,最好是web工程的和java工程 各一个例子, 同时天涯沦落人啊!! [b]问题补充:[/b] 谢谢 楼上兄弟的给你资料和建议,我现在除了拷贝了log4j-1.2.11.jar 和commons-logging-1.0.4.jar 这两个文件外,还在hibernate下拷贝了一个log4j.property的属性文件,都放置到了src下面,但是现在又出下面错误: 22:11:54,599 INFO Environment:514 - Hibernate 3.2.6 22:11:54,619 INFO Environment:547 - hibernate.properties not found 22:11:54,629 INFO Environment:681 - Bytecode provider name : cglib 22:11:54,639 INFO Environment:598 - using JDK 1.4 java.sql.Timestamp handling 22:11:54,850 INFO Configuration:1432 - configuring from resource: /hibernate.cfg.xml 22:11:54,850 INFO Configuration:1409 - Configuration resource: /hibernate.cfg.xml 22:11:55,501 INFO Configuration:559 - Reading mappings from resource : hib.hbm.xml 22:11:56,212 INFO HbmBinder:300 - Mapping class: FirstBean -> student org.hibernate.InvalidMappingException: Could not parse mapping document from resource hib.hbm.xml at org.hibernate.cfg.Configuration.addResource(Configuration.java:575) at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1593) 其中: 一:22:11:54,619 INFO Environment:547 - hibernate.properties not found 提示没有找到hibernate.properties 是怎么会事?我已经放置hibernate.properties,这个文件不是自己写,因为我不会写,就在hibernate下拷贝的一个,请大家给出建议,谢谢 二:org.hibernate.InvalidMappingException: Could not parse mapping document from resource hib.hbm.xml 这个实际上是提示没有找到hib.hbm.xml映射文件,我很是奇怪,无论我怎么修改<mapping resource="hib.hbm.xml">的映射路径,都是不可以的!请大家帮助!! 学习中,望大家指点 谢谢
org.hibernate.HibernateException: No Session found for current thread
<div class="iteye-blog-content-contain" style="font-size: 14px;"> <p><span style="font-size: 12px; line-height: 1.5;">hibernate:4.1.6</span><br style="line-height: 24px; background-color: #f2f8ef;"><span style="font-size: 12px; line-height: 1.5;">spring:4.0.1<br></span></p> <p> </p> <p><span style="font-size: 12px; line-height: 1.5;">工程启动没错,进入getAllUser页面获得数据库用户信息时报如下错误: </span></p> <p> </p> <p>严重: Servlet.service() for servlet springMVC threw exception</p> <p>org.hibernate.HibernateException: No Session found for current thread</p> <p>at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:106)</p> <p>at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:941)</p> <p>at com.mlf.web.controller.dao.UserDAO.getAllUser(UserDAO.java:27)</p> <p>at com.mlf.web.controller.service.UserManager.getAllUser(UserManager.java:28)</p> <p>at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</p> <p>at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)</p> <p>at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)</p> <p>at java.lang.reflect.Method.invoke(Method.java:597)</p> <p>at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)</p> <p>at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)</p> <p>at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)</p> <p>at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)</p> <p>at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)</p> <p>at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)</p> <p>at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)</p> <p>at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)</p> <p>at $Proxy19.getAllUser(Unknown Source)</p> <p>at com.mlf.web.controller.UserController.getAllUser(UserController.java:36)</p> <p>at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</p> <p>at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)</p> <p>at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)</p> <p>at java.lang.reflect.Method.invoke(Method.java:597)</p> <p>at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:214)</p> <p>at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)</p> <p>at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)</p> <p>at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)</p> <p>at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:690)</p> <p>at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)</p> <p>at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)</p> <p>at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)</p> <p>at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)</p> <p>at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)</p> <p>at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)</p> <p>at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)</p> <p>at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)</p> <p>at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)</p> <p>at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)</p> <p>at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:149)</p> <p>at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)</p> <p>at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)</p> <p>at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)</p> <p>at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)</p> <p>at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)</p> <p>at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)</p> <p>at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)</p> <p>at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)</p> <p>at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)</p> <p>at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)</p> <p>at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)</p> <p>at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)</p> <p>at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)</p> <p>at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)</p> <p>at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617)</p> <p>at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1760)</p> <p>at java.lang.Thread.run(Thread.java:619)</p> <p>-----------------------------------------------------------------------------------------------------------------------------------------</p> <p>hibernate.cfg.test.xml(com.mlf.web.controller.hibernate)</p> <p> </p> <pre name="code" class="xml">&lt;?xml version='1.0' encoding='utf-8'?&gt; &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt; &lt;hibernate-configuration&gt; &lt;session-factory&gt; &lt;mapping class="com.mlf.web.controller.entity.User"/&gt; &lt;/session-factory&gt; &lt;/hibernate-configuration&gt;</pre> <p> <span style="font-size: 12px; line-height: 1.5;">-----------------------------------------------------------------------------------------------------------------------------------------</span></p> <p> </p> <p><span style="font-size: 12px; line-height: 1.5;">applicationContext.xml(com.mlf.web.controller.spring)</span></p> <p> </p> <pre name="code" class="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd" [ &lt;!ENTITY contextInclude SYSTEM "org/springframework/web/context/WEB-INF/contextInclude.xml"&gt; ]&gt; &lt;beans&gt; &lt;bean id="userDao" class="com.mlf.web.controller.dao.UserDAO"&gt; &lt;property name="sessionFactory" ref="sessionFactory"&gt;&lt;/property&gt; &lt;/bean&gt; &lt;bean id="userManagerBase" class="com.mlf.web.controller.service.UserManager"&gt; &lt;property name="userDao" ref="userDao"&gt;&lt;/property&gt; &lt;/bean&gt; &lt;bean id="userManager" parent="transactionBese"&gt; &lt;property name="target" ref="userManagerBase"&gt;&lt;/property&gt; &lt;/bean&gt; &lt;/beans&gt; </pre> <p> <span style="font-size: 12px; line-height: 1.5;"> </span><span style="font-size: 12px; line-height: 1.5;">-----------------------------------------------------------------------------------------------------------------------------------------</span></p> <p> </p> <p><span style="font-size: 12px; line-height: 1.5;">spring-annotation.xml(包:config)</span></p> <p> </p> <pre name="code" class="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"&gt; &lt;!-- 扫描包 --&gt; &lt;context:component-scan base-package="com.mlf.web.controller"&gt;&lt;/context:component-scan&gt; &lt;!-- 开启注解 --&gt; &lt;mvc:annotation-driven/&gt; &lt;!-- &lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt;&lt;/bean&gt; &lt;bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"&gt;&lt;/bean&gt; --&gt; &lt;!-- 静态资源访问 --&gt; &lt;mvc:resources location="/img/" mapping="/img/**"/&gt; &lt;mvc:resources location="/js/" mapping="/js/**"/&gt; &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;property name="prefix" value="/"&gt;&lt;/property&gt; &lt;property name="suffix" value=".jsp"&gt;&lt;/property&gt; &lt;/bean&gt; &lt;!-- 配置文件上传解析器 --&gt; &lt;bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt; &lt;property name="defaultEncoding" value="utf-8"/&gt; &lt;!-- 文件最大值 --&gt; &lt;property name="maxUploadSize" value="10485760000"/&gt; &lt;!-- 缓存大小 --&gt; &lt;property name="maxInMemorySize" value="40960"/&gt; &lt;/bean&gt; &lt;/beans&gt;</pre> <p> <span style="font-size: 12px; line-height: 1.5;"> </span><span style="font-size: 12px; line-height: 1.5;"> </span><span style="font-size: 12px; line-height: 1.5;">-----------------------------------------------------------------------------------------------------------------------------------------</span></p> <p> </p> <p><span style="font-size: 12px; line-height: 1.5;">spring-core.xml(</span><span style="font-size: 12px; line-height: 1.5;">包:config</span><span style="font-size: 12px; line-height: 1.5;">)</span></p> <p> </p> <pre name="code" class="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd" [ &lt;!ENTITY contextInclude SYSTEM "org/springframework/web/context/WEB-INF/contextInclude.xml"&gt; ]&gt; &lt;beans&gt; &lt;import resource="classpath:com/mlf/web/controller/spring/applicationContext.xml"/&gt; &lt;/beans&gt; </pre> <p> <span style="font-size: 12px; line-height: 1.5;"> </span><span style="font-size: 12px; line-height: 1.5;"> </span><span style="font-size: 12px; line-height: 1.5;"> </span><span style="font-size: 12px; line-height: 1.5;">-----------------------------------------------------------------------------------------------------------------------------------------</span></p> <p> </p> <p><span style="font-size: 12px; line-height: 1.5;">spring-hibernate.xml(</span><span style="font-size: 12px; line-height: 1.5;">包:config</span><span style="font-size: 12px; line-height: 1.5;">)</span></p> <p> </p> <pre name="code" class="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd" [ &lt;!ENTITY contextInclude SYSTEM "org/springframework/web/context/WEB-INF/contextInclude.xml"&gt; ]&gt; &lt;beans&gt; &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt; &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"&gt;&lt;/property&gt; &lt;property name="url" value="jdbc:mysql://localhost:3306/test?useUnicode=true&amp;amp;characterEncodeing=utf-8"&gt;&lt;/property&gt; &lt;property name="username" value="root"&gt;&lt;/property&gt; &lt;property name="password" value="donny2014"&gt;&lt;/property&gt; &lt;/bean&gt; &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource"&gt;&lt;/property&gt; &lt;property name="hibernateProperties"&gt; &lt;props&gt; &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLInnoDBDialect&lt;/prop&gt; &lt;!-- 自动更新 --&gt; &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt; &lt;!-- 在控制台打印SQL语句 --&gt; &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt; &lt;!-- 将SQL脚本进行格式化后再输出 --&gt; &lt;prop key="hibernate.format_sql"&gt;true&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;property name="configLocations"&gt; &lt;list&gt; &lt;value&gt; classpath:com/mlf/web/controller/hibernate/hibernate.cfg.test.xml &lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt; &lt;property name="sessionFactory" ref="sessionFactory"&gt;&lt;/property&gt; &lt;/bean&gt; &lt;!-- 配置事务 --&gt; &lt;bean id="transactionBese" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" lazy-init="true" abstract="true"&gt; &lt;property name="transactionManager" ref="transactionManager"&gt;&lt;/property&gt; &lt;property name="transactionAttributes"&gt; &lt;props&gt; &lt;prop key="add*"&gt;PROPAGATION_REQUIRED,-Exception&lt;/prop&gt; &lt;prop key="update*"&gt;PROPAGATION_REQUIRED,-Exception&lt;/prop&gt; &lt;prop key="insert*"&gt;PROPAGATION_REQUIRED,-Exception&lt;/prop&gt; &lt;prop key="modify*"&gt;PROPAGATION_REQUIRED,-Exception&lt;/prop&gt; &lt;prop key="delete*"&gt;PROPAGATION_REQUIRED,-Exception&lt;/prop&gt; &lt;prop key="get*"&gt;PROPAGATION_NEVER&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;/bean&gt; &lt;/beans&gt; </pre> <p> <span style="font-size: 12px; line-height: 1.5;"> </span><span style="font-size: 12px; line-height: 1.5;"> </span><span style="font-size: 12px; line-height: 1.5;"> </span><span style="font-size: 12px; line-height: 1.5;"> </span><span style="font-size: 12px; line-height: 1.5;">-----------------------------------------------------------------------------------------------------------------------------------------</span></p> <p> </p> <p><span style="font-size: 12px; line-height: 1.5;">UserController.java(包:</span><span style="font-size: 12px; line-height: 1.5;">com.mlf.web.controller</span><span style="font-size: 12px; line-height: 1.5;">)</span></p> <p> </p> <pre name="code" class="java">package com.mlf.web.controller; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.mlf.web.controller.entity.User; import com.mlf.web.controller.service.IUserManager; @Controller @RequestMapping("/user") public class UserController { @Resource(name="userManager") private IUserManager userManager; @RequestMapping("/toAddUser") public String toAddUser(){ return "/addUser"; } @RequestMapping("/addUser") public String addUser(User user){ userManager.addUser(user); return "/success"; } @RequestMapping("/getAllUser") public String getAllUser(HttpServletRequest request){ List&lt;User&gt; user = userManager.getAllUser(); request.setAttribute("user", user); return "/userManager"; } } </pre> <p> </p> </div>
spring 的问题!困饶我很长时间了,谁能帮我解决下,谢谢!
我不知道我在哪里出了问题,但是总是出错,说我的数据引入类型不对,请大家帮下我,下面是我的代码: 控制台报的错误为: [code="java"] 2008-8-18 23:21:23 org.apache.catalina.core.ApplicationDispatcher invoke 严重: Servlet.service() for servlet jsp threw exception java.lang.NumberFormatException: For input string: "name" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java:447) at java.lang.Integer.parseInt(Integer.java:497) at javax.el.ArrayELResolver.coerce(ArrayELResolver.java:153) at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:45) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53) at org.apache.el.parser.AstValue.getValue(AstValue.java:97) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:923) at org.apache.jsp.category.categoryList_jsp._jspx_meth_c_005fforEach_005f0(categoryList_jsp.java:129) at org.apache.jsp.category.categoryList_jsp._jspService(categoryList_jsp.java:83) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292) at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:111) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:965) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:744) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:663) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:394) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:348) at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:595) [/code] categoryDAO接口: [code="java"] package com.ngworld.bookstore.dao; import java.util.List; public interface CategoryDao extends BaseDao{ public List getCategoryList(); } [/code] categoryHibernate实现类: [code="java"] package com.ngworld.bookstore.hibernate; import java.util.List; import com.ngworld.bookstore.dao.CategoryDao; public class CategoryHibernate extends BaseHibernate implements CategoryDao { public List getCategoryList() { // TODO Auto-generated method stub String hql="from Category p left join p.department order by p.id"; return getHibernateTemplate().find(hql); } } [/code] categoryService接口: [code="java"] package com.ngworld.bookstore.service; import java.util.List; public interface CategoryService { public List getCategoryList(); } [/code] categoryManager实现类: [code="java"] package com.ngworld.bookstore.manager; import java.util.List; import com.ngworld.bookstore.dao.CategoryDao; import com.ngworld.bookstore.service.CategoryService; public class CategoryManager implements CategoryService { private CategoryDao categoryDao; public void setCategoryDao(CategoryDao categoryDao) { this.categoryDao = categoryDao; } public List getCategoryList() { // TODO Auto-generated method stub return categoryDao.getCategoryList(); } } [/code] categoryController实现类: [code="java"] package com.ngworld.bookstore.manager; import java.util.List; import com.ngworld.bookstore.dao.CategoryDao; import com.ngworld.bookstore.service.CategoryService; public class CategoryManager implements CategoryService { private CategoryDao categoryDao; public void setCategoryDao(CategoryDao categoryDao) { this.categoryDao = categoryDao; } public List getCategoryList() { // TODO Auto-generated method stub return categoryDao.getCategoryList(); } } [/code] applicationContext-Dao文件: [code="java"] <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="com.mysql.jdbc.Driver"/> <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/hbstpdb?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=GBK"/> <property name="user" value="root"/> <property name="password" value="root"/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <!-- <prop key="show_sql">true</prop> <prop key="schema">hbstpdb</prop> --> </props> </property> <property name="mappingResources"> <list> <value>com/ngworld/bookstore/vo/Category.hbm.xml</value> <value>com/ngworld/bookstore/vo/Bookcategory.hbm.xml</value> <value>com/ngworld/bookstore/vo/Department.hbm.xml</value> <value>com/ngworld/bookstore/vo/Book.hbm.xml</value> <value>com/ngworld/bookstore/vo/Shoppingcart.hbm.xml</value> </list> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <bean id="txProxyTemplate" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" lazy-init="true" abstract="true"> <property name="transactionManager"> <ref bean="transactionManager" /> </property> <property name="transactionAttributes"> <props> <prop key="save*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="remove*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="update*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property> </bean> <!-- 目录分类 --> <bean id="categoryDao" class="com.ngworld.bookstore.hibernate.CategoryHibernate"> <property name="sessionFactory"><ref bean="sessionFactory"/></property> </bean> [/code] applicationContext-Service配置文件: [code="java"] <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <bean id="categoryManagerTarget" class="com.ngworld.bookstore.manager.CategoryManager"> <property name="categoryDao"><ref bean="categoryDao"/></property> </bean> <bean id="categoryService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" parent="txProxyTemplate"> <property name="target"><ref bean="categoryManagerTarget"/></property> </bean> [/code] applicationContext-Servlet配置文件: [code="java"] <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="interceptors"> <list> <bean class="com.ngworld.insurancecard.interceptor.RequestEncodingInterceptor"/> </list> </property> <property name="mappings"> <props> <!-- 目录模块 --> <prop key="/category/categorylist.do">categoryListController</prop> </props> </property> </bean> <!-- 目录模块 --> <bean id="categoryListController" class="com.ngworld.bookstore.controller.category.CategoryListController"> <property name="categoryService"> <ref bean="categoryService"/> </property> </bean> [/code] 我的categroy表: categroyID DepartmentID Name Description 1 1 computer computer 2 2 science science 我的department表: DepartmentID Name Desrciption 1 computer computer 2 science science 这是我的表记录 谢谢大家帮我解决下问题,谢谢,这个问题已经困绕我很长时间了! [b]问题补充:[/b] 抱歉,昨天贴的比较着急忘了贴出pojo文件和hibernate.hbm.xml文件了 我在这里补下: pojo文件: category表的pojo文件: package com.ngworld.bookstore.vo; import java.util.HashSet; import java.util.Set; /** * Category generated by MyEclipse Persistence Tools */ public class Category extends com.ngworld.bookstore.vo.BaseVo implements java.io.Serializable { // Fields private Integer categoryId; private Department department; private String name; private String description; private Set bookcategories = new HashSet(0); // Constructors /** default constructor */ public Category() { } /** minimal constructor */ public Category(Department department, String name) { this.department = department; this.name = name; } /** full constructor */ public Category(Department department, String name, String description, Set bookcategories) { this.department = department; this.name = name; this.description = description; this.bookcategories = bookcategories; } // Property accessors public Integer getCategoryId() { return this.categoryId; } public void setCategoryId(Integer categoryId) { this.categoryId = categoryId; } public Department getDepartment() { return this.department; } public void setDepartment(Department department) { this.department = department; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getDescription() { return this.description; } public void setDescription(String description) { this.description = description; } public Set getBookcategories() { return this.bookcategories; } public void setBookcategories(Set bookcategories) { this.bookcategories = bookcategories; } } department的pojo文件 package com.ngworld.bookstore.vo; import java.util.HashSet; import java.util.Set; /** * Department generated by MyEclipse Persistence Tools */ public class Department extends com.ngworld.bookstore.vo.BaseVo implements java.io.Serializable { // Fields private Integer departmentId; private String name; private String description; private Set categories = new HashSet(0); // Constructors /** default constructor */ public Department() { } /** minimal constructor */ public Department(String name) { this.name = name; } /** full constructor */ public Department(String name, String description, Set categories) { this.name = name; this.description = description; this.categories = categories; } // Property accessors public Integer getDepartmentId() { return this.departmentId; } public void setDepartmentId(Integer departmentId) { this.departmentId = departmentId; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getDescription() { return this.description; } public void setDescription(String description) { this.description = description; } public Set getCategories() { return this.categories; } public void setCategories(Set categories) { this.categories = categories; } } .hbm.xml文件: category.hbm.xml文件 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Mapping file autogenerated by MyEclipse Persistence Tools --> <hibernate-mapping> <class name="com.ngworld.bookstore.vo.Category" table="category" > <id name="categoryId" type="java.lang.Integer"> <column name="CategoryID" /> <generator class="increment" /> </id> <many-to-one name="department" class="com.ngworld.bookstore.vo.Department" fetch="select"> <column name="DepartmentID" not-null="true" /> </many-to-one> <property name="name" type="java.lang.String"> <column name="Name" length="50" not-null="true" /> </property> <property name="description" type="java.lang.String"> <column name="Description" length="1000" /> </property> <set name="bookcategories" inverse="true"> <key> <column name="CategoryID" not-null="true" /> </key> <one-to-many class="com.ngworld.bookstore.vo.Bookcategory" /> </set> </class> </hibernate-mapping> department.hbm.xml文件: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Mapping file autogenerated by MyEclipse Persistence Tools --> <hibernate-mapping> <class name="com.ngworld.bookstore.vo.Department" table="department"> <id name="departmentId" type="java.lang.Integer"> <column name="DepartmentID" /> <generator class="increment" /> </id> <property name="name" type="java.lang.String"> <column name="Name" length="50" not-null="true" /> </property> <property name="description" type="java.lang.String"> <column name="Description" length="1000" /> </property> <set name="categories" inverse="true"> <key> <column name="DepartmentID" not-null="true" /> </key> <one-to-many class="com.ngworld.bookstore.vo.Category" /> </set> </class> </hibernate-mapping> 这个是我的jsp文件: <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>分类管理</title> </head> <body> <form action="#" name="frm"> <table width="75%" border="1" align="center"> <tr align="center"> <td colspan="4">信息列表</td> </tr> <tr> <td colspan="4">目录管理&gt;&gt;分类管理&gt;&gt;信息管理</td> </tr> <tr> <td>分类编号</td> <td>分类名称</td> <td>部门</td> <td>部门种类</td> </tr> <c:forEach items="${categoryList}" var="categoryList" varStatus="status"> <tr> <td><c:out value="${status.index+1}"/></td> <td>${categoryList.name}</td> <td>${categoryList.department}</td> <td>${categoryList.description }</td> </tr> </c:forEach> </table> </form> </body> </html> 我知道意思是string类型转化为number类型的错误,但是我不知道哪里出的问题,谢谢大家帮我解决下! [b]问题补充:[/b] 上面的categoryController文件贴错了 这里是我的categoryController文件 [code="java"] package com.ngworld.bookstore.controller.category; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.validation.BindException; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.Controller; import com.ngworld.bookstore.service.CategoryService; import com.ngworld.bookstore.vo.Category; public class CategoryListController implements Controller{ private CategoryService categoryService; public void setCategoryService(CategoryService categoryService) { this.categoryService = categoryService; } public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { // TODO Auto-generated method stub List categoryList=categoryService.getCategoryList(); request.setAttribute("categoryList",categoryList); return new ModelAndView("/category/categoryList.jsp"); } } [/code]
进度条不能运行的问题
我想填充进度条,但是没有实现。 MainActivity : package com.example.progressbar; import android.os.Bundle; import android.os.Handler; import android.app.Activity; import android.app.ProgressDialog; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public abstract class MainActivity2 extends Activity { int progressStatus = 0; int fileSize = 0; ProgressDialog progress; Button button; Handler h=new Handler(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); buttonClick(); } public void buttonClick(){ button=(Button)findViewById(R.id.button1); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { progress=new ProgressDialog(v.getContext()); progress.setCancelable(true); progress.setMessage("File Downloading.."); progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progress.setProgress(0); progress.setMax(100); progress.show(); new Thread(new Runnable() { @Override public void run() { while (progressStatus<=100) { progressStatus=doOperation(); try{ Thread.sleep(1000); } //end of try catch (Exception e) { e.printStackTrace(); }// End of the Catch h.post(new Runnable() { @Override public void run() { // TODO Auto-generated method stub progress.setProgress(progressStatus); }); //end of post } // end of while if (progressStatus>=100) { try{ Thread.sleep(4000); }catch (Exception e) { e.printStackTrace(); } progress.dismiss(); } } // end of run }).start(); } //end of on click method }); //end of new on click listener } private int doOperation() { while(fileSize<=10000){ ++fileSize; if(fileSize==1000){ return 10; } if(fileSize==2000){ return 20; } if(fileSize==3000){ return 30; } if(fileSize==4000){ return 40; } if(fileSize==5000){ return 50; } if(fileSize==6000){ return 60; } if(fileSize==7000){ return 70; } if(fileSize==8000){ return 80; } if(fileSize==9000){ return 90; } if(fileSize==10000){ return 100; } //end of while return 100; } // end of doOperation() } // End of the class Exception: 09-10 09:56:12.719: D/dalvikvm(553): newInstance failed: p0 i0 [0 a1 09-10 09:56:12.770: D/AndroidRuntime(553): Shutting down VM 09-10 09:56:12.770: W/dalvikvm(553): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 09-10 09:56:12.890: E/AndroidRuntime(553): FATAL EXCEPTION: main 09-10 09:56:12.890: E/AndroidRuntime(553): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.progressbar/com.example.progressbar.MainActivity}: java.lang.InstantiationException: com.example.progressbar.MainActivity 09-10 09:56:12.890: E/AndroidRuntime(553): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585) 09-10 09:56:12.890: E/AndroidRuntime(553): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 09-10 09:56:12.890: E/AndroidRuntime(553): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 09-10 09:56:12.890: E/AndroidRuntime(553): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 09-10 09:56:12.890: E/AndroidRuntime(553): at android.os.Handler.dispatchMessage(Handler.java:99) 09-10 09:56:12.890: E/AndroidRuntime(553): at android.os.Looper.loop(Looper.java:123) 09-10 09:56:12.890: E/AndroidRuntime(553): at android.app.ActivityThread.main(ActivityThread.java:4627) 09-10 09:56:12.890: E/AndroidRuntime(553): at java.lang.reflect.Method.invokeNative(Native Method) 09-10 09:56:12.890: E/AndroidRuntime(553): at java.lang.reflect.Method.invoke(Method.java:521) 09-10 09:56:12.890: E/AndroidRuntime(553): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 09-10 09:56:12.890: E/AndroidRuntime(553): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 09-10 09:56:12.890: E/AndroidRuntime(553): at dalvik.system.NativeStart.main(Native Method) 09-10 09:56:12.890: E/AndroidRuntime(553): Caused by: java.lang.InstantiationException: com.example.progressbar.MainActivity 09-10 09:56:12.890: E/AndroidRuntime(553): at java.lang.Class.newInstanceImpl(Native Method) 09-10 09:56:12.890: E/AndroidRuntime(553): at java.lang.Class.newInstance(Class.java:1429) 09-10 09:56:12.890: E/AndroidRuntime(553): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 09-10 09:56:12.890: E/AndroidRuntime(553): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577) 09-10 09:56:12.890: E/AndroidRuntime(553): ... 11 more 09-10 09:59:38.939: D/dalvikvm(581): newInstance failed: p0 i0 [0 a1 09-10 09:59:38.939: D/AndroidRuntime(581): Shutting down VM 09-10 09:59:38.979: W/dalvikvm(581): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 09-10 09:59:39.059: E/AndroidRuntime(581): FATAL EXCEPTION: main 09-10 09:59:39.059: E/AndroidRuntime(581): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.progressbar/com.example.progressbar.MainActivity}: java.lang.InstantiationException: com.example.progressbar.MainActivity 09-10 09:59:39.059: E/AndroidRuntime(581): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585) 09-10 09:59:39.059: E/AndroidRuntime(581): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 09-10 09:59:39.059: E/AndroidRuntime(581): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 09-10 09:59:39.059: E/AndroidRuntime(581): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 09-10 09:59:39.059: E/AndroidRuntime(581): at android.os.Handler.dispatchMessage(Handler.java:99) 09-10 09:59:39.059: E/AndroidRuntime(581): at android.os.Looper.loop(Looper.java:123) 09-10 09:59:39.059: E/AndroidRuntime(581): at android.app.ActivityThread.main(ActivityThread.java:4627) 09-10 09:59:39.059: E/AndroidRuntime(581): at java.lang.reflect.Method.invokeNative(Native Method) 09-10 09:59:39.059: E/AndroidRuntime(581): at java.lang.reflect.Method.invoke(Method.java:521) 09-10 09:59:39.059: E/AndroidRuntime(581): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 09-10 09:59:39.059: E/AndroidRuntime(581): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 09-10 09:59:39.059: E/AndroidRuntime(581): at dalvik.system.NativeStart.main(Native Method) 09-10 09:59:39.059: E/AndroidRuntime(581): Caused by: java.lang.InstantiationException: com.example.progressbar.MainActivity 09-10 09:59:39.059: E/AndroidRuntime(581): at java.lang.Class.newInstanceImpl(Native Method) 09-10 09:59:39.059: E/AndroidRuntime(581): at java.lang.Class.newInstance(Class.java:1429) 09-10 09:59:39.059: E/AndroidRuntime(581): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 09-10 09:59:39.059: E/AndroidRuntime(581): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577) 09-10 09:59:39.059: E/AndroidRuntime(581): ... 11 more 09-10 10:04:39.199: I/Process(581): Sending signal. PID: 581 SIG: 9 09-10 10:09:58.549: D/dalvikvm(609): newInstance failed: p0 i0 [0 a1 09-10 10:09:58.590: D/AndroidRuntime(609): Shutting down VM 09-10 10:09:58.590: W/dalvikvm(609): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 09-10 10:09:58.629: E/AndroidRuntime(609): FATAL EXCEPTION: main 09-10 10:09:58.629: E/AndroidRuntime(609): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.progressbar/com.example.progressbar.MainActivity}: java.lang.InstantiationException: com.example.progressbar.MainActivity 09-10 10:09:58.629: E/AndroidRuntime(609): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585) 09-10 10:09:58.629: E/AndroidRuntime(609): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 09-10 10:09:58.629: E/AndroidRuntime(609): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 09-10 10:09:58.629: E/AndroidRuntime(609): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 09-10 10:09:58.629: E/AndroidRuntime(609): at android.os.Handler.dispatchMessage(Handler.java:99) 09-10 10:09:58.629: E/AndroidRuntime(609): at android.os.Looper.loop(Looper.java:123) 09-10 10:09:58.629: E/AndroidRuntime(609): at android.app.ActivityThread.main(ActivityThread.java:4627) 09-10 10:09:58.629: E/AndroidRuntime(609): at java.lang.reflect.Method.invokeNative(Native Method) 09-10 10:09:58.629: E/AndroidRuntime(609): at java.lang.reflect.Method.invoke(Method.java:521) 09-10 10:09:58.629: E/AndroidRuntime(609): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 09-10 10:09:58.629: E/AndroidRuntime(609): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 09-10 10:09:58.629: E/AndroidRuntime(609): at dalvik.system.NativeStart.main(Native Method) 09-10 10:09:58.629: E/AndroidRuntime(609): Caused by: java.lang.InstantiationException: com.example.progressbar.MainActivity 09-10 10:09:58.629: E/AndroidRuntime(609): at java.lang.Class.newInstanceImpl(Native Method) 09-10 10:09:58.629: E/AndroidRuntime(609): at java.lang.Class.newInstance(Class.java:1429) 09-10 10:09:58.629: E/AndroidRuntime(609): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 09-10 10:09:58.629: E/AndroidRuntime(609): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577) 09-10 10:09:58.629: E/AndroidRuntime(609): ... 11 more 09-10 10:10:05.819: I/Process(609): Sending signal. PID: 609 SIG: 9 09-10 10:17:26.139: W/KeyCharacterMap(723): No keyboard for id 0 09-10 10:17:26.150: W/KeyCharacterMap(723): Using default keymap: /system/usr/keychars/qwerty.kcm.bin 09-10 10:19:15.472: W/KeyCharacterMap(781): No keyboard for id 0 09-10 10:19:15.472: W/KeyCharacterMap(781): Using default keymap: /system/usr/keychars/qwerty.kcm.bin 09-10 10:43:31.709: D/dalvikvm(866): newInstance failed: p0 i0 [0 a1 09-10 10:43:31.709: D/AndroidRuntime(866): Shutting down VM 09-10 10:43:31.740: W/dalvikvm(866): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 09-10 10:43:31.759: E/AndroidRuntime(866): FATAL EXCEPTION: main 09-10 10:43:31.759: E/AndroidRuntime(866): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.progressbar/com.example.progressbar.MainActivity2}: java.lang.InstantiationException: com.example.progressbar.MainActivity2 09-10 10:43:31.759: E/AndroidRuntime(866): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585) 09-10 10:43:31.759: E/AndroidRuntime(866): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 09-10 10:43:31.759: E/AndroidRuntime(866): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 09-10 10:43:31.759: E/AndroidRuntime(866): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 09-10 10:43:31.759: E/AndroidRuntime(866): at android.os.Handler.dispatchMessage(Handler.java:99) 09-10 10:43:31.759: E/AndroidRuntime(866): at android.os.Looper.loop(Looper.java:123) 09-10 10:43:31.759: E/AndroidRuntime(866): at android.app.ActivityThread.main(ActivityThread.java:4627) 09-10 10:43:31.759: E/AndroidRuntime(866): at java.lang.reflect.Method.invokeNative(Native Method) 09-10 10:43:31.759: E/AndroidRuntime(866): at java.lang.reflect.Method.invoke(Method.java:521) 09-10 10:43:31.759: E/AndroidRuntime(866): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 09-10 10:43:31.759: E/AndroidRuntime(866): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 09-10 10:43:31.759: E/AndroidRuntime(866): at dalvik.system.NativeStart.main(Native Method) 09-10 10:43:31.759: E/AndroidRuntime(866): Caused by: java.lang.InstantiationException: com.example.progressbar.MainActivity2 09-10 10:43:31.759: E/AndroidRuntime(866): at java.lang.Class.newInstanceImpl(Native Method) 09-10 10:43:31.759: E/AndroidRuntime(866): at java.lang.Class.newInstance(Class.java:1429) 09-10 10:43:31.759: E/AndroidRuntime(866): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 09-10 10:43:31.759: E/AndroidRuntime(866): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577) 09-10 10:43:31.759: E/AndroidRuntime(866): ... 11 more
setResultTransformer(Transformers.aliasToBean(..))
以前一直用jdbc做开发,取出的数据放在为每个表建立的数据类中,想放表的哪几个字段就放哪几个 现在想学学hibernate,用oracle的原生sql想取出一个表中的两列: String selectTopicSql = "select topic,sectorname from article order by topic desc"; query = session.createSQLQuery(selectTopicSql1).setResultTransformer(Transformers.aliasToBean(Article.class)); Article.java就是hibernate对表ARTICLE的映射类,其配置文件如下: <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > <hibernate-mapping package="test"> <class name="Article" table="ARTICLE" > <meta attribute="sync-DAO">false</meta> <id name="topic" column="TOPIC" type="string"> <generator class="native"/> </id> <property name="Sectorname" column="SECTORNAME" type="string" not-null="true" length="40" /> <property name="Contents" column="CONTENTS" type="string" /> <property name="Keyword" column="KEYWORD" type="string" length="40" /> <property name="Source" column="SOURCE" type="string" length="100" /> <property name="Pageview" column="PAGEVIEW" type="integer" length="10" /> <property name="Score" column="SCORE" type="big_decimal" length="2" /> <property name="Createtime" column="CREATETIME" type="date" length="7" update="false" /> <property name="Updatetime" column="UPDATETIME" type="date" length="7" update="false" /> </class> </hibernate-mapping> 该配置文件在执行全字段检索没有问题,现在只取topic,sectorname就报错: Exception in thread "main" org.hibernate.PropertyNotFoundException: Could not find setter for TOPIC on class test.Article at org.hibernate.property.ChainedPropertyAccessor.getSetter(ChainedPropertyAccessor.java:68) at org.hibernate.transform.AliasToBeanResultTransformer.transformTuple(AliasToBeanResultTransformer.java:87) at org.hibernate.hql.HolderInstantiator.instantiate(HolderInstantiator.java:92) at org.hibernate.loader.custom.CustomLoader.getResultList(CustomLoader.java:353) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125) at org.hibernate.loader.Loader.list(Loader.java:2120) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1722) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175) at com.struts_learn.dao.ArticleDAO.selectTopic(ArticleDAO.java:58) at com.struts_learn.dao.ArticleDAO.main(ArticleDAO.java:206) 看了源码没看明白,如果另外再写一个jdbc那种数据类,何必用hibernate的映射类,如果不这样是不是就不能只取两个字段?我那个表的其他字段有很大的,不想全取出来,一直听说hibernate是持久层牛X框架,今日一见实在是失望,搞这么个东西在jdbc不用10分钟,竟然在hibernate里搞了半天也没能用映射类Article.java实现! 希望有对hibernate老手指点下! package test; import test.base.BaseArticle; import java.math.*; public class Article extends BaseArticle { private static final long serialVersionUID = 1L; /*[CONSTRUCTOR MARKER BEGIN]*/ public Article () { super(); } /** * Constructor for primary key */ public Article (java.lang.String topic) { super(topic); } /** * Constructor for required fields */ public Article ( java.lang.String topic, java.lang.String sectorname, java.lang.String contents, java.lang.String keyword, java.lang.String source, java.lang.Integer pageview, java.math.BigDecimal score, java.util.Date createtime, java.util.Date updatetime) { super ( topic, sectorname, contents, keyword, source, pageview, score, createtime, updatetime); } /*[CONSTRUCTOR MARKER END]*/ } package test.base; import java.io.Serializable; /** * This is an object that contains data related to the ARTICLE table. * Do not modify this class because it will be overwritten if the configuration file * related to this class is modified. * * @hibernate.class * table="ARTICLE" */ public abstract class BaseArticle implements Serializable { public static String REF = "Article"; public static String PROP_PAGEVIEW = "Pageview"; public static String PROP_KEYWORD = "Keyword"; public static String PROP_TOPIC = "Topic"; public static String PROP_UPDATETIME = "Updatetime"; public static String PROP_SCORE = "Score"; public static String PROP_CONTENTS = "Contents"; public static String PROP_CREATETIME = "Createtime"; public static String PROP_SOURCE = "Source"; public static String PROP_SECTORNAME = "Sectorname"; // constructors public BaseArticle () { initialize(); } /** * Constructor for primary key */ public BaseArticle (java.lang.String topic) { this.setTopic(topic); initialize(); } /** * Constructor for required fields */ public BaseArticle ( java.lang.String topic, java.lang.String sectorname, java.lang.String contents, java.lang.String keyword, java.lang.String source, java.lang.Integer pageview, java.math.BigDecimal score, java.util.Date createtime, java.util.Date updatetime) { this.setTopic(topic); this.setSectorname(sectorname); this.setContents(contents); this.setKeyword(keyword); this.setSource(source); this.setPageview(pageview); this.setScore(score); this.setCreatetime(createtime); this.setUpdatetime(updatetime); initialize(); } protected void initialize () {} private int hashCode = Integer.MIN_VALUE; // primary key private java.lang.String topic; // fields private java.lang.String sectorname; private java.lang.String contents; private java.lang.String keyword; private java.lang.String source; private java.lang.Integer pageview; private java.math.BigDecimal score; private java.util.Date createtime; private java.util.Date updatetime; /** * Return the unique identifier of this class * @hibernate.id * generator-class="native" * column="TOPIC" */ public java.lang.String getTopic () { return topic; } /** * Set the unique identifier of this class * @param topic the new ID */ public void setTopic (java.lang.String topic) { this.topic = topic; this.hashCode = Integer.MIN_VALUE; } /** * Return the value associated with the column: SECTORNAME */ public java.lang.String getSectorname () { return sectorname; } /** * Set the value related to the column: SECTORNAME * @param sectorname the SECTORNAME value */ public void setSectorname (java.lang.String sectorname) { this.sectorname = sectorname; } /** * Return the value associated with the column: CONTENTS */ public java.lang.String getContents () { return contents; } /** * Set the value related to the column: CONTENTS * @param contents the CONTENTS value */ public void setContents (java.lang.String contents) { this.contents = contents; } /** * Return the value associated with the column: KEYWORD */ public java.lang.String getKeyword () { return keyword; } /** * Set the value related to the column: KEYWORD * @param keyword the KEYWORD value */ public void setKeyword (java.lang.String keyword) { this.keyword = keyword; } /** * Return the value associated with the column: SOURCE */ public java.lang.String getSource () { return source; } /** * Set the value related to the column: SOURCE * @param source the SOURCE value */ public void setSource (java.lang.String source) { this.source = source; } /** * Return the value associated with the column: PAGEVIEW */ public java.lang.Integer getPageview () { return pageview; } /** * Set the value related to the column: PAGEVIEW * @param pageview the PAGEVIEW value */ public void setPageview (java.lang.Integer pageview) { this.pageview = pageview; } /** * Return the value associated with the column: SCORE */ public java.math.BigDecimal getScore () { return score; } /** * Set the value related to the column: SCORE * @param score the SCORE value */ public void setScore (java.math.BigDecimal score) { this.score = score; } /** * Return the value associated with the column: CREATETIME */ public java.util.Date getCreatetime () { return createtime; } /** * Set the value related to the column: CREATETIME * @param createtime the CREATETIME value */ public void setCreatetime (java.util.Date createtime) { this.createtime = createtime; } /** * Return the value associated with the column: UPDATETIME */ public java.util.Date getUpdatetime () { return updatetime; } /** * Set the value related to the column: UPDATETIME * @param updatetime the UPDATETIME value */ public void setUpdatetime (java.util.Date updatetime) { this.updatetime = updatetime; } public boolean equals (Object obj) { if (null == obj) return false; if (!(obj instanceof test.Article)) return false; else { test.Article article = (test.Article) obj; if (null == this.getTopic() || null == article.getTopic()) return false; else return (this.getTopic().equals(article.getTopic())); } } public int hashCode () { if (Integer.MIN_VALUE == this.hashCode) { if (null == this.getTopic()) return super.hashCode(); else { String hashStr = this.getClass().getName() + ":" + this.getTopic().hashCode(); this.hashCode = hashStr.hashCode(); } } return this.hashCode; } public String toString () { return super.toString(); } }
ssh+oracle开发 部署的时候报错
2009-8-31 4:57:43 org.apache.catalina.core.StandardContext listenerStart 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:380) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1112) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:423) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:285) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342) at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1116) at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1214) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590) at java.lang.Thread.run(Unknown Source) 2009-8-31 4:57:43 org.apache.catalina.core.StandardContext start 严重: Error listenerStart 2009-8-31 4:57:43 org.apache.catalina.core.StandardContext start 严重: Context [/guestbook3] startup failed due to previous errors 2009-8-31 4:57:43 org.apache.catalina.core.ApplicationContext log [b]问题补充:[/b] 这是我的配置文件 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" value="dataSource"> </property> <property name="mappingResources"> <list> <value>com/v512/guestbook/model/Guestbook.hbm.xml </value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect </prop> </props> </property> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"> </property> <property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl"> </property> <property name="username" value="scott"> </property> <property name="password" value="tiger"> </property> </bean> <bean id="guestbookDao" class="com.v512.guestbook.dao.hibernate.GuestbookDaoHibernate" abstract="false" lazy-init="default" autowire="default" dependency-check="default"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="guestbookManager" class="com.v512.guestbook.service.impl.GuestbookManagerImpl" abstract="false" lazy-init="default" autowire="default" dependency-check="default"> <property name="guestbookDao"> <ref bean="guestbookDao" /> </property> </bean> </beans>
c3p0报错,版本为最新,求大神帮忙!!!!!!!!
详细:之前都是好使的,因为需要,所配置的事务,加上事务后,运行到加注解的方法就报错。 依赖 ``` <!--c3p0--> <dependency> <groupId>com.mchange</groupId> <artifactId>c3p0</artifactId> <version>0.9.5.2</version> </dependency> <!--aop依赖--> <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjrt --> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>1.8.9</version> </dependency> <!--aop依赖,shiro权限需要--> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.7.4</version> </dependency> <!-- https://mvnrepository.com/artifact/com.google.zxing/javase --> <dependency> <groupId>com.google.zxing</groupId> <artifactId>javase</artifactId> <version>2.1</version> </dependency> <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifactId> <version>2.2.3</version> </dependency> <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz-jobs</artifactId> <version>2.2.3</version> </dependency> ``` 配置 ``` <!--开启AOP的对类代理--> <aop:aspectj-autoproxy proxy-target-class="true"/> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="${db.driver}"/> <property name="jdbcUrl" value="${db.url}"/> <property name="user" value="${db.username}"/> <property name="password" value="${db.password}"/> <property name="maxIdleTime" value="${db.maxIdleTime}"/> <property name="maxPoolSize" value="${db.maxPoolSize}"/> <property name="minPoolSize" value="${db.minPoolSize}"/> <property name="initialPoolSize" value="${db.initialPoolSize}"/> <property name="acquireRetryDelay" value="${db.acquireRetryDelay}"/> <property name="acquireIncrement" value="${db.acquireIncrement}"/> <property name="acquireRetryAttempts" value="${db.acquireRetryAttempts}"/> <property name="breakAfterAcquireFailure" value="${db.breakAfterAcquireFailure}"/> </bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="configLocation" value="classpath:mybatis-config.xml"/> <property name="dataSource" ref="dataSource"/> </bean> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.chao"/> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> </bean> <!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <!-- 注解方式配置事物 --> <tx:annotation-driven transaction-manager="transactionManager" /> ``` 错误信息: 严重: Servlet.service() for servlet [SpringServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.AbstractMethodError: Method com/mchange/v2/c3p0/impl/NewProxyPreparedStatement.isClosed()Z is abstract] with root cause java.lang.AbstractMethodError: Method com/mchange/v2/c3p0/impl/NewProxyPreparedStatement.isClosed()Z is abstract at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.isClosed(NewProxyPreparedStatement.java) at org.apache.ibatis.executor.BaseExecutor.closeStatement(BaseExecutor.java:285) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:65) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) at com.github.pagehelper.PageInterceptor.executeAutoCount(PageInterceptor.java:201) at com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:113) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) at com.sun.proxy.$Proxy31.query(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) at com.sun.proxy.$Proxy27.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230) at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:139) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:76) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
请问keyEvent cannot be resolved to a type 怎么解决?
这是我写了一半的贪吃蛇代码,但是我却无法解决键盘事件的一个问题。这些代码是我照着参考书的键盘事件写的。请问我的代码出现了什么问题? 问题: Exception in thread "main" java.lang.Error: Unresolved compilation problems: The method addKeyListener(KeyListener) in the type Component is not applicable for the arguments (new PythonGame_Java.KeyListener(){}) The type new PythonGame_Java.KeyListener(){} must implement the inherited abstract method PythonGame_Java.KeyListener.keyPressed(keyEvent) keyEvent cannot be resolved to a type The method game(Graphics) in the type DrawPanel is not applicable for the arguments () at 挑战Java编贪吃蛇.PythonGame_Java.main(PythonGame_Java.java:30) 代码如下: ``` package 挑战Java编贪吃蛇; import java.awt.*; import java.awt.event.KeyEvent; import java.util.EventListener; import javax.swing.*; import java.io.*; public class PythonGame_Java extends JFrame{ //蟒蛇游戏(贪吃蛇) Java语言 (我之前用Python编了类似的程序) public PythonGame_Java(){ //<init> super(); init(); } public interface KeyListener extends EventListener{ public void keyPressed(keyEvent e); } public void init(){ this.setSize(900,600); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setContentPane(new DrawPanel()); this.setTitle("Java贪吃蛇"); setResizable(false); setVisible(true); } public static void main(String[] args) throws InterruptedException { PythonGame_Java Game = new PythonGame_Java(); JTextArea textArea = new JTextArea(); textArea.addKeyListener(new KeyListener() { public void keyPressed(keyEvent e){ String keyTest=KeyEvent.getKeyText(e.getKeyCode()); System.out.println(keyTest); } }); class DrawPanel extends JPanel{ //蛇身宽度=10 private boolean started=true; private final int wait_time=300; private int snake[][]=new int[10000][2]; private int length=0; private int currx=0; private int curry=0; private int BonusX=10; private int BonusY=10; private int loopnum=0; private String snake_dir="right"; public void main(String[] args){ game(); } public void game(Graphics g) throws InterruptedException{ snake[0][0]=0; snake[0][1]=0; while(started==true){ g.setColor(Color.WHITE); g.fillRect(0,0,900,600); g.setColor(Color.BLUE); for(int i=0;i<=length;i++) g.fillRect(snake[i][0]*10,snake[i][1]*10,10,10); switch(snake_dir){ case "left": currx--; case "right": currx++; case "up": curry--; case "down": curry++; } if(currx<0) currx=0; if(curry<0) curry=0; if(currx>90) currx=90; if(curry>60) curry=60; snake[loopnum][0]=currx; snake[loopnum][1]=curry; loopnum++; if(loopnum>length) loopnum=0; if(currx==BonusX && curry==BonusY){ length++; BonusX=(int)(Math.random())*91; BonusY=(int)(Math.random())*61; } Thread.sleep(wait_time); } //游戏循环结束 } //游戏函数结束 } //子类结束 }} //父类结束? ```
SHH 配置问题
点击提交按钮出现的异常. 在action中打断点无反应,应该是在进入之前就产生了此异常 [code="java"] [ERROR][2009-08-04 00:26:10] - [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/extdemo].[action]] -org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260) - -Servlet.service() for servlet action threw exception org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/login' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userService' of bean class [com.extdemo.struts.action.LoginAction]: Bean property 'userService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'userService' of bean class [com.extdemo.struts.action.LoginAction]: Bean property 'userService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:793) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1127) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:270) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:737) at org.springframework.web.struts.DelegatingRequestProcessor.getDelegateAction(DelegatingRequestProcessor.java:168) at org.springframework.web.struts.DelegatingRequestProcessor.processActionCreate(DelegatingRequestProcessor.java:146) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:230) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:834) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:640) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1286) at java.lang.Thread.run(Thread.java:595) [/code] applicationContext.xml [code="java"] <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <bean id="transactionProxyFactory" abstract="true" lazy-init="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"> <ref local="transactionManager" /> </property> <property name="target"> <ref local="UserDAO" /> </property> <property name="transactionAttributes"> <props> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="insert*">PROPAGATION_REQUIRED</prop> <prop key="del*">PROPAGATION_REQUIRED</prop> <prop key="add*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="create*">PROPAGATION_REQUIRED</prop> <prop key="*">PROPAGATION_REQUIRED, readOnly</prop> </props> </property> </bean> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <!--==================== DAO======================= --> <bean id="UserDAO" class="com.extdemo.dao.impl.UserDAO"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <!--====================Service======================= --> <bean id="UserService" class="com.extdemo.service.impl.UserService"> <property name="userDAO"> <ref local="UserDAO" /> </property> </bean> <!--====================Action======================= --> <bean name="/login" class="com.extdemo.struts.action.LoginAction" scope="prototype"> <property name="userService" > <ref local="UserService"/> </property> </bean> </beans> [/code] IUserService接口类 [code="java"] public interface IUserService { public User findUserById(String id); public List<User> findByUserName(String userName); public void Save(User user); } [/code] IUserService实现类 [code="java"] public class UserService implements IUserService { private IUserDAO userDAO; public IUserDAO getUserDAO() { return userDAO; } public void setUserDAO(IUserDAO userDAO) { this.userDAO = userDAO; } public void Save(User user) { userDAO.save(user); } public List<User> findByUserName(String userName) { List<User> list = userDAO.findByName(userName); if (list.size() == 0) { return null; } else { return (List<User>) list.get(0); } } public User findUserById(String id) { return userDAO.findById(id); } } [/code] action [code="java"] public class LoginAction extends Action { private UserService userService; public UserService getService() { return userService; } public void setService(UserService userService) { this.userService = userService; } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { LoginForm loginForm = (LoginForm) form; String username = loginForm.getUsername(); String password = loginForm.getPassword(); ActionForward forward = mapping.getInputForward(); User user = (User) userService.findByUserName(username); if (user.getPassword().equals(password)) { forward = mapping.findForward("sucess"); } return forward; } } [/code] struts-config.xml [code="java"] <action-mappings> <action path="/login" type="com.extdemo.struts.action.LoginAction" attribute="loginForm" name="loginForm" scope="request"> <forward name="success" path="/index.jsp" /> </action> </action-mappings> <controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"> </controller> <message-resources parameter="com.extdemo.struts.ApplicationResources" /> <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> <set-property property="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml" /> </plug-in> [/code] web.xml [code="java"] <!-- Spring 配置 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/classes/applicationContext.xml </param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> [/code] 从异常来看 应该是struts和spring的配置问题 以前没接触过spring 所有照搬网上的配置问题无从下手 \ 环境 struts1.2+hibernate3.1+spring2.5+tomcat5.5 IDE : lomboz3.2+myeclipse5.5 整了一天,都快1点了.. 帮忙解决下,先谢谢了.. [b]问题补充:[/b] 分给谁呢?? 我晕倒 谢谢3位了。
请教,泛型DAO调试不通,提示java.lang.NullPointerException。
刚刚接触学习泛型DAO,按照网上的一个例子来写,运行就提示,Exception in thread "main" java.lang.NullPointerException。开发环境是myeclipse6.5,jdk5.0,只好来这里请教,代码如下: [code="java"]文件列表1: 文件名 说明 IDao.java dao的顶层抽象接口 AbstractDao.java IDao的实现类,实现了get/update/delete等基本操作 User.java USER表对应的entity定义 IUserDao.java USER表操作DAO接口定义 UserDao.java USER表操作DAO实现 HelloGenerics.java 测试类 IDao.java // super dao interface public interface IDao <T, PK extends Serializable> { public T get(PK pk); public List <T>getAll(); public PK save(T entity); public void update(T entity); public void saveOrUpdate(T entity); public void delete(T entity); } AbstractDao.java //super abstract dao class public abstract class AbstractDao <T, PK extends Serializable>implements IDao<T, PK> { private Class clz; public AbstractDao(Class clz) { this.clz = clz; } public T get(PK pk) { return (T)getSession().get(clz, pk); } public List <T>getAll() { return getSession().createCriteria(clz).list(); } public PK save(T entity) { return (PK)getSession().save(entity); } public void update(T entity) { getSession().update(entity); } public void saveOrUpdate(T entity) { getSession().saveOrUpdate(entity); } public void delete(T entity) { getSession().delete(entity); } private Session session; protected Session getSession() { //wrap session in a class such as HibernateUtils, then you can use HibernateUtils.getCurrentSession() for getting a session. return session; } } User.java //persist entity public class User { private String id; private String name; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } //... setter/getter HERE } IUserDao.java //User Dao interface public interface IUserDao extends IDao <User, String> { // all are empty } UserDao.java //UserDao Implementation public class UserDao extends AbstractDao <User, String> implements IUserDao { public UserDao() { super(User.class); } // or use the following constructor //public UserDao(Class<User> type) { // super(type); //} } HelloGenerics.java public class HelloGenerics { public static void main(String[] args) { IUserDao userDao = new UserDao(); User user = userDao.get("1"); if (user != null) { System.out.println(user.getName()); } List<User> userList = userDao.getAll(); for (User u:userList) { System.out.println(user.getName()); } } }[/code]
Sping+struts2+hibernate的空指针问题,小弟太着急了
<p><br><img src="http://dl.iteye.com/upload/attachment/281567/94aaf2fb-b1f5-3f60-a421-116de03e7d5c.png" alt=""><br> 搭一个Sping+struts2+hibernate的框架,出现空指针问题:</p> <pre name="code" class="LoginAction">package com.user.action; import com.opensymphony.xwork2.ActionSupport; import com.user.dao.PersonManager; import com.user.vo.Person; public class LoginAction extends ActionSupport{ private String username; private String password; private PersonManager personManager; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public PersonManager getPersonManager() { return personManager; } public void setPersonManager(PersonManager personManager) { this.personManager = personManager; } @Override public String execute() throws Exception { String flag = ""; Person per = new Person(); per.setUname(this.username); per.setUpwd(this.password); if(personManager.isLogin(per)){ flag = "success"; } else{ flag = "fail"; } return flag; } } </pre> <p> </p> <pre name="code" class="PersonManager">package com.user.dao; import java.util.List; import org.hibernate.Query; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import com.user.vo.Person; public class PersonManager extends HibernateDaoSupport{ public boolean isLogin(Person per){ boolean flag = false; String hql = "From Person as p where p.uname=? and p.upwd=?"; Query q = this.getSession().createQuery(hql); q.setString(0, per.getUname()); q.setString(1, per.getUpwd()); List all = q.list(); if(all.size() &gt; 0){ flag = true; } else{ flag = false; } return flag; } } </pre> <p> </p> <pre name="code" class="Person">package com.user.vo; public class Person implements java.io.Serializable { private Integer id; private String uname; private String upwd; public Person() { } public Person(Integer id) { this.id = id; } public Person(Integer id, String uname, String upwd) { this.id = id; this.uname = uname; this.upwd = upwd; } public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } public String getUname() { return this.uname; } public void setUname(String uname) { this.uname = uname; } public String getUpwd() { return this.upwd; } public void setUpwd(String upwd) { this.upwd = upwd; } } </pre> <p> </p> <pre name="code" class="person.hbm.xml">&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt; &lt;hibernate-mapping&gt; &lt;class name="com.user.vo.Person" table="person" catalog="MAIN"&gt; &lt;id name="id" type="java.lang.Integer"&gt; &lt;column name="id" length="4" /&gt; &lt;/id&gt; &lt;property name="uname" type="java.lang.String"&gt; &lt;column name="uname" length="20" /&gt; &lt;/property&gt; &lt;property name="upwd" type="java.lang.String"&gt; &lt;column name="upwd" length="20" /&gt; &lt;/property&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </pre> <p> </p> <pre name="code" class="applicationContext.xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt; &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"&gt; &lt;property name="driverClassName" value="org.gjt.mm.mysql.Driver"&gt; &lt;/property&gt; &lt;property name="url" value="jdbc:mysql://localhost:3306/MAIN"&gt;&lt;/property&gt; &lt;property name="username" value="tooy"&gt;&lt;/property&gt; &lt;property name="password" value="root"&gt;&lt;/property&gt; &lt;/bean&gt; &lt;bean id="exampleHibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"&gt; &lt;property name="properties"&gt; &lt;props&gt; &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt; &lt;prop key="hibernate.query.substitutions"&gt; true 'T', false 'F' &lt;/prop&gt; &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt; &lt;prop key="hibernate.c3p0.minPoolSize"&gt;5&lt;/prop&gt; &lt;prop key="hibernate.c3p0.maxPoolSize"&gt;20&lt;/prop&gt; &lt;prop key="hibernate.c3p0.timeout"&gt;600&lt;/prop&gt; &lt;prop key="hibernate.c3p0.max_statement"&gt;50&lt;/prop&gt; &lt;prop key="hibernate.c3p0.testConnectionOnCheckout"&gt; false &lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt; &lt;property name="dataSource"&gt; &lt;ref bean="dataSource" /&gt; &lt;/property&gt; &lt;property name="hibernateProperties"&gt; &lt;props&gt; &lt;prop key="hibernate.dialect"&gt; org.hibernate.dialect.MySQLDialect &lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;property name="mappingResources"&gt; &lt;list&gt; &lt;value&gt;com/user/vo/Person.hbm.xml&lt;/value&gt;&lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; &lt;!-- 配置PersonManager.java类文件 --&gt; &lt;bean id="personManager" class="com.user.dao.PersonManager" abstract="false" lazy-init="default" autowire="default" dependency-check="default"&gt; &lt;property name="sessionFactory" &gt; &lt;ref local="sessionFactory"/&gt; &lt;/property&gt; &lt;/bean&gt; &lt;!-- 配置LoginAction.java类文件 --&gt; &lt;bean id="loginAction" class="com.user.action.LoginAction" &gt; &lt;property name="personManager"&gt; &lt;ref bean="personManager" /&gt; &lt;/property&gt; &lt;/bean&gt; &lt;/beans&gt; </pre> <p> </p> <pre name="code" class="struts.xml">&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"&gt; &lt;struts&gt; &lt;constant name="struts.objectFactory" value="spring"&gt;&lt;/constant&gt; &lt;!-- Rose India Struts 2 Tutorials --&gt; &lt;constant name="struts.enable.DynamicMethodInvocation" value="false" /&gt; &lt;constant name="struts.devMode" value="true" /&gt; &lt;!--导入struts-default.xml文件 --&gt; &lt;include file="struts-default.xml"&gt;&lt;/include&gt; &lt;!-- 配置中文支持 --&gt; &lt;constant name="struts.i18n.encoding" value="GBK"&gt;&lt;/constant&gt; &lt;!-- 配置Action --&gt; &lt;package name="struts" extends="struts-default" namespace="/"&gt; &lt;action name="login" class="com.user.action.LoginAction"&gt; &lt;result name="success"&gt;/result.jsp&lt;/result&gt; &lt;result name="fail"&gt;/error.jsp&lt;/result&gt; &lt;/action&gt; &lt;/package&gt; &lt;/struts&gt; </pre> <p> </p> <pre name="code" class="web.xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt; &lt;!-- 配置spring的监听器 --&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;classpath*:/applicationContext_hibernate.xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;!-- 开启监听 --&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;!-- Struts2 配置 --&gt; &lt;filter&gt; &lt;filter-name&gt;struts2&lt;/filter-name&gt; &lt;filter-class&gt;org.apache.struts2.dispatcher.FilterDispatcher&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;struts2&lt;/filter-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; &lt;welcome-file-list&gt; &lt;welcome-file&gt;login.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;/web-app&gt; </pre> <p> </p> <pre name="code" class="login.jsp">&lt;%@ page language="java" contentType="text/HTML;charset=GBK" pageEncoding="GBK"%&gt; &lt;%@ taglib prefix="s" uri="/struts-tags"%&gt; &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt; &lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;center&gt; &lt;s:form action="login" method="POST" namespace="/"&gt; &lt;s:textfield name="username" label="用户名" size="14"/&gt; &lt;s:password name="password" label="密 码" size="14"/&gt; &lt;s:submit label="提交" /&gt; &lt;/s:form&gt; &lt;/center&gt; &lt;/body&gt; &lt;/html&gt; </pre> <p><span> 错误:</span></p> <h3>Stacktraces</h3> <div class="stacktrace" style="padding-left: 0em;"> <strong>java.lang.NullPointerException</strong> <div> <pre> com.user.action.LoginAction.execute(LoginAction.java:45) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) java.lang.reflect.Method.invoke(Unknown Source) com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441) com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243) com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252) org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488) org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) java.lang.Thread.run(Unknown Source) </pre> </div> </div>
java程序不知道哪里错了,求指教
不知道哪里错了,求指教 程序如下: package com.Sixping.Ncre; import java.util.*; public class AbstractClassTest { public static void main(String[] args) { Person[] people=new Person[2]; people[0]=new Employee0("张浩", 50000, 1989, 10, 1); people[1]=new Student0("李明", "计算机科学"); for(Person p:people){ System.out.println(p.getName()+","+p.getDescription()); } } } abstract class Person{ public Person(String n) { name=n; } public abstract String getDescription(); public String getName(){ return name; } private String name; } class Employee0 extends Person{ public Employee0(String n,double s,int year,int mouth ,int day){ super(n); salary=s; GregorianCalendar calendar=new GregorianCalendar(year ,mouth-1,day); hireDay=calendar.getTime(); } public String getDescription() { return String.format("公司雇员,年薪是¥%。2f。", salary); } private double salary; private Date hireDay; } class Student0 extends Person{ public Student0(String n, String m) { super(n); major=m; } public String grtDescription() { return "大学生,专业是"+major+"。"; } private String major; } 错误信息: Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '。' at java.util.Formatter.checkText(Formatter.java:2502) at java.util.Formatter.parse(Formatter.java:2484) at java.util.Formatter.format(Formatter.java:2413) at java.util.Formatter.format(Formatter.java:2366) at java.lang.String.format(String.java:2770) at com.Sixping.Ncre.Employee0.getDescription(AbstractClassTest.java:34) at com.Sixping.Ncre.AbstractClassTest.main(AbstractClassTest.java:11)
Spring配置文件的问题
提示错误 : Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.lfw.sh.manager.impl.UserManagerImpl#10b4b2f' defined in class path resource [applicationContext-commom.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is required java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is required Spring配置文件如下: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"> </property> <property name="url" value="jdbc:mysql://localhost:3306/test"></property> <property name="username" value="root"></property> <property name="password" value="88888888"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql"> true </prop> </props> </property> <property name="mappingResources"> <list> <value>com/lfw/sh/domin/User.hbm.xml</value> </list> </property></bean> <!--Hibernate TransactionManager--> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <!--Base TransactionProxyed Service Bean--> <bean id="baseTxService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true"> <property name="transactionManager" ref="transactionManager"/> <property name="proxyTargetClass" value="true"/> <property name="transactionAttributes"> <props> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="updateBillSeq*">PROPAGATION_REQUIRED,ISOLATION_SERIALIZABLE</prop> <prop key="remove*">PROPAGATION_REQUIRED</prop> <prop key="submit*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <bean id="userManager" parent="baseTxService"> <property name="target"> <bean class="com.lfw.sh.manager.impl.UserManagerImpl" /> </property> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> </beans> 我明明已经注入了sessionFactory了呀,怎么还是提示找不到的? [b]问题补充:[/b] UserManagerImpl类已经继承了HibernateDaoSupport类
想整合struts2.2.1与spring3.1.0,出现了一点麻烦,请各位给点建议,谢谢关注
<pre name="code" class="xml"> &lt;bean id="loginDao" class="com.test.dao.login.impl.LoginDaoImpl"/&gt; &lt;bean id="loginService" class = "com.test.service.impl.LoginServiceImpl" scope="prototype"&gt; &lt;property name="loginDao"&gt; &lt;ref bean = "loginDao"/&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="loginActionBean" class="com.test.action.LoginAction" scope="prototype"&gt; &lt;property name="loginService"&gt; &lt;ref bean = "loginService"/&gt; &lt;/property&gt; &lt;/bean&gt;</pre> <p> 上面是applicationContext.xml的配置。</p> <p> </p> <pre name="code" class="java">package com.test.action; import com.test.base.BaseAction; import com.test.service.LoginService; public class LoginAction extends BaseAction{ private String userName = null; private String password = null; private LoginService loginService; public LoginService getLoginService() { return loginService; } public void setLoginService(LoginService loginService) { this.loginService = loginService; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String execute() throws Exception { System.out.println("=========用户民:"+getUserName()); System.out.println("=========密 码:"+getPassword()); return loginService.login(getUserName(),getPassword()); } }</pre> <p> 上面是action的代码</p> <p> </p> <pre name="code" class="java">public interface LoginDao { public String login(String userName, String password); }</pre> <p>上面是loginDao接口。</p> <p> </p> <p> </p> <pre name="code" class="java">public class LoginDaoImpl extends BaseAction implements LoginDao{ public String login(String userName, String password) { if(isInvalid(userName)||isInvalid(password)){ return LOGIN; }else if(userName.equals("Tom") &amp;&amp; password.equals("123456")){ return SUCCESS; }else{ return LOGIN; } } }</pre> <p>上面是logiDao的实现类LoginDaoImpl。</p> <p> </p> <pre name="code" class="java">public interface LoginService{ public abstract String login(String userName, String password); }</pre> <p>上面是loginService接口。</p> <p> </p> <pre name="code" class="java">public class LoginServiceImpl implements LoginService{ LoginDao dao; public LoginServiceImpl(LoginDao dao){ this.dao = dao; } public String login(String userName, String password){ return this.dao.login(userName, password); } }</pre> <p> 上面是loginService的实现类LoginServiceImpl。</p> <p> </p> <p>基于上述代码运行后,会报出以下异常:</p> <p> </p> <pre name="code" class="html">type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: java.lang.NullPointerException org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88) root cause java.lang.NullPointerException org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:792) org.apache.struts2.components.UIBean.end(UIBean.java:510) org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42) org.apache.jsp.login_jsp._jspx_meth_s_005ftextfield_005f0(login_jsp.java:185) org.apache.jsp.login_jsp._jspx_meth_s_005fform_005f0(login_jsp.java:141) org.apache.jsp.login_jsp._jspService(login_jsp.java:78) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88) </pre> <p> </p> <p>jdk控制台的打印信息如下:</p> <p> </p> <pre name="code" class="c">2011-4-17 11:48:21 com.opensymphony.xwork2.util.logging.commons.CommonsLogger er ror 严重: Could not open template org.springframework.beans.factory.BeanCreationException: Error creating bean wit h name 'loginActionBean' defined in file [D:\workspace\test\WebContent\WEB-IN F\classes\applicationContext.xml]: Cannot resolve reference to bean 'loginServic e' while setting bean property 'loginService'; nested exception is org.springfra mework.beans.factory.BeanCreationException: Error creating bean with name 'login Service' defined in file [D:\workspace\test\WebContent\WEB-INF\classes\applic ationContext.xml]: Instantiation of bean failed; nested exception is org.springf ramework.beans.BeanInstantiationException: Could not instantiate bean class [com .test.service.impl.LoginServiceImpl]: No default constructor found; nested ex ception is java.lang.NoSuchMethodException: com.test.service.impl.LoginServic eImpl.&lt;init&gt;() at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveReference(BeanDefinitionValueResolver.java:328) at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveValueIfNecessary(BeanDefinitionValueResolver.java:106) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1086) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe an(AbstractBeanFactory.java:314) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:194) at org.springframework.context.support.AbstractApplicationContext.getBea n(AbstractApplicationContext.java:1080) at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(S pringObjectFactory.java:221) at org.apache.struts2.components.ServletUrlRenderer.renderFormUrl(Servle tUrlRenderer.java:161) at org.apache.struts2.components.Form.populateComponentHtmlId(Form.java: 220) at org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:784) at org.apache.struts2.components.ClosingUIBean.start(ClosingUIBean.java: 57) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(Component TagSupport.java:53) at org.apache.jsp.login_jsp._jspx_meth_s_005fform_005f0(login_jsp.java:1 30) at org.apache.jsp.login_jsp._jspService(login_jsp.java:78) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper .java:374) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3 42) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:206) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter .doFilter(StrutsPrepareAndExecuteFilter.java:88) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav a:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java :849) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce ss(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:45 4) at java.lang.Thread.run(Thread.java:619) Caused by: org.springframework.beans.factory.BeanCreationException: Error creati ng bean with name 'loginService' defined in file [D:\workspace\test\WebConten t\WEB-INF\classes\applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not ins tantiate bean class [com.test.service.impl.LoginServiceImpl]: No default cons tructor found; nested exception is java.lang.NoSuchMethodException: com.test. service.impl.LoginServiceImpl.&lt;init&gt;() at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe an(AbstractBeanFactory.java:314) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveReference(BeanDefinitionValueResolver.java:322) ... 37 more Caused by: org.springframework.beans.BeanInstantiationException: Could not insta ntiate bean class [com.test.service.impl.LoginServiceImpl]: No default constr uctor found; nested exception is java.lang.NoSuchMethodException: com.test.se rvice.impl.LoginServiceImpl.&lt;init&gt;() at org.springframework.beans.factory.support.SimpleInstantiationStrategy .instantiate(SimpleInstantiationStrategy.java:70) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958) ... 43 more Caused by: java.lang.NoSuchMethodException: com.test.service.impl.LoginServic eImpl.&lt;init&gt;() at java.lang.Class.getConstructor0(Class.java:2706) at java.lang.Class.getDeclaredConstructor(Class.java:1985) at org.springframework.beans.factory.support.SimpleInstantiationStrategy .instantiate(SimpleInstantiationStrategy.java:65) ... 44 more org.springframework.beans.factory.BeanCreationException: Error creating bean wit h name 'loginActionBean' defined in file [D:\workspace\test\WebContent\WEB-IN F\classes\applicationContext.xml]: Cannot resolve reference to bean 'loginServic e' while setting bean property 'loginService'; nested exception is org.springfra mework.beans.factory.BeanCreationException: Error creating bean with name 'login Service' defined in file [D:\workspace\test\WebContent\WEB-INF\classes\applic ationContext.xml]: Instantiation of bean failed; nested exception is org.springf ramework.beans.BeanInstantiationException: Could not instantiate bean class [com .test.service.impl.LoginServiceImpl]: No default constructor found; nested ex ception is java.lang.NoSuchMethodException: com.test.service.impl.LoginServic eImpl.&lt;init&gt;() at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveReference(BeanDefinitionValueResolver.java:328) at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveValueIfNecessary(BeanDefinitionValueResolver.java:106) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1086) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe an(AbstractBeanFactory.java:314) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:194) at org.springframework.context.support.AbstractApplicationContext.getBea n(AbstractApplicationContext.java:1080) at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(S pringObjectFactory.java:221) at org.apache.struts2.components.ServletUrlRenderer.renderFormUrl(Servle tUrlRenderer.java:161) at org.apache.struts2.components.Form.populateComponentHtmlId(Form.java: 220) at org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:784) at org.apache.struts2.components.ClosingUIBean.start(ClosingUIBean.java: 57) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(Component TagSupport.java:53) at org.apache.jsp.login_jsp._jspx_meth_s_005fform_005f0(login_jsp.java:1 30) at org.apache.jsp.login_jsp._jspService(login_jsp.java:78) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper .java:374) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3 42) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:206) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter .doFilter(StrutsPrepareAndExecuteFilter.java:88) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav a:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java :849) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce ss(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:45 4) at java.lang.Thread.run(Thread.java:619) Caused by: org.springframework.beans.factory.BeanCreationException: Error creati ng bean with name 'loginService' defined in file [D:\workspace\test\WebConten t\WEB-INF\classes\applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not ins tantiate bean class [com.test.service.impl.LoginServiceImpl]: No default cons tructor found; nested exception is java.lang.NoSuchMethodException: com.test. service.impl.LoginServiceImpl.&lt;init&gt;() at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe an(AbstractBeanFactory.java:314) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.BeanDefinitionValueResolver .resolveReference(BeanDefinitionValueResolver.java:322) ... 37 more Caused by: org.springframework.beans.BeanInstantiationException: Could not insta ntiate bean class [com.test.service.impl.LoginServiceImpl]: No default constr uctor found; nested exception is java.lang.NoSuchMethodException: com.test.se rvice.impl.LoginServiceImpl.&lt;init&gt;() at org.springframework.beans.factory.support.SimpleInstantiationStrategy .instantiate(SimpleInstantiationStrategy.java:70) at org.springframework.beans.factory.support.AbstractAutowireCapableBean Factory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958) ... 43 more Caused by: java.lang.NoSuchMethodException: com.test.service.impl.LoginServic eImpl.&lt;init&gt;() at java.lang.Class.getConstructor0(Class.java:2706) at java.lang.Class.getDeclaredConstructor(Class.java:1985) at org.springframework.beans.factory.support.SimpleInstantiationStrategy .instantiate(SimpleInstantiationStrategy.java:65) ... 44 more </pre> <p> </p> <p>请各位高手看看,这是什么原因哈,struts2配置没有问题的,因为已经测试过了,struts.xml的配置如下:</p> <pre name="code" class="xml">&lt;struts&gt; &lt;package name="login" extends="struts-default"&gt; &lt;action name="login" class= "loginActionBean"&gt; &lt;result name="success"&gt;/success.jsp&lt;/result&gt; &lt;result name="login"&gt;/error.jsp&lt;/result&gt; &lt;/action&gt; &lt;!-- Add actions here --&gt; &lt;/package&gt; &lt;/struts&gt;</pre> <p> </p>
Spring 3.0+ Hibernate 3.3 泛型 注解管理Bean 出现问题 郁闷!
参照网上的Demo 自己也弄了个泛型注解 BaseDao 里面 的gedao 是null 高手们给看一下 [code="java"]package com.zw.core; import java.io.Serializable; import java.util.List; public interface IBaseDao<T, PK extends Serializable> { public T getById(PK id); public List<T> getAll(); public T load(PK id); public void load(T entityObject, PK id); public void delete(T entityObject); public void deleteById(PK id); public void refresh(T entityObject); public void evict(T entityObject); public void save(T entityObject); public void clear(); }[/code] [code="java"]package com.zw.core; import java.io.Serializable; import java.util.List; public class BaseDao<T, PK extends Serializable> implements IBaseDao<T, PK> { protected Class<T> entityClass;// DAO所管理的Entity类型. private GenericEntityDao<T, PK> gedao; public Class<T> getEntityClass() { return entityClass; } public void setEntityClass(Class<T> entityClass) { this.entityClass = entityClass; } public GenericEntityDao<T, PK> getGedao() { return gedao; } public void setGedao(GenericEntityDao<T, PK> gedao) { this.gedao = gedao; } /** * 让spring提供构造函数注入 */ public BaseDao(Class<T> type) { this.entityClass = type; } public BaseDao() { } public void delete(T entityObject) { gedao.delete(entityObject); } public void deleteById(PK id) { gedao.deleteById(id); } public void evict(T entityObject) { gedao.evict(entityObject); } public List<T> getAll() { return gedao.getAll(); } public T getById(PK id) { return gedao.getById(id); } public T load(PK id) { return gedao.load(id); } public void load(T entityObject, PK id) { gedao.load(entityObject, id); } public T merge(T entityObject) { return gedao.merge(entityObject); } public void refresh(T entityObject) { gedao.refresh(entityObject); } public void save(T entityObject) { System.out.println("gedao:"+gedao); gedao.save(entityObject); } public void clear() { } } [/code] [code="java"]package com.zw.core; import java.io.Serializable; import java.util.List; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; public class GenericEntityDao<T, PK extends Serializable> extends HibernateDaoSupport { protected Class<T> entityClass;// DAO所管理的Entity类型. public GenericEntityDao() { } public GenericEntityDao(Class<T> entityClass) { this.entityClass = entityClass; } @SuppressWarnings("unchecked") public T getById(PK id) { return (T) this.getHibernateTemplate().get(this.entityClass, id); } @SuppressWarnings("unchecked") public List<T> getAll() { return (List<T>) (this.getHibernateTemplate().loadAll(this.entityClass)); } @SuppressWarnings("unchecked") public T load(PK id) { return (T) this.getHibernateTemplate().load(this.entityClass, id); } public void load(T entityObject, PK id) { this.getHibernateTemplate().load(entityObject, id); } public void delete(T entityObject) { this.getHibernateTemplate().delete(entityObject); } public void deleteById(PK id) { this.delete(this.getById(id)); } public void refresh(T entityObject) { this.getHibernateTemplate().refresh(entityObject); } public void evict(T entityObject) { this.getHibernateTemplate().evict(entityObject); } public void save(T entityObject) { this.getHibernateTemplate().saveOrUpdate(entityObject); } @SuppressWarnings("unchecked") public T merge(T entityObject) { return (T) this.getHibernateTemplate().merge(entityObject); } } [/code] ToplMSoftDAO [code="java"]package com.zw.dao; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.stereotype.Repository; import com.zw.core.BaseDao; import com.zw.domain.ToplMSoft; @Repository("toplMSoftDAO") public class ToplMSoftDAO extends BaseDao<ToplMSoft,Integer> { private static final Log log = LogFactory.getLog(ToplMSoftDAO.class); } [/code] [code="java"] <?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:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 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-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> <!-- 使用外部文件配置数据源的属性 --> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <!-- 外部文件地址 --> <value>classpath:database_conn.properties </value> </list> </property> <property name="fileEncoding" value="utf-8" /> </bean> <!-- 配置数据源 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="${driverClassName}" /> <property name="jdbcUrl" value="${url}" /> <property name="user" value="${username}" /> <property name="password" value="${password}" /> <property name="minPoolSize" value="5" /> <property name="maxPoolSize" value="20" /> <property name="initialPoolSize" value="10" /> <property name="maxIdleTime" value="60" /> <property name="acquireIncrement" value="5" /> <property name="maxStatements" value="0" /> <property name="idleConnectionTestPeriod" value="60" /> <property name="acquireRetryAttempts" value="30" /> <property name="breakAfterAcquireFailure" value="true" /> <property name="testConnectionOnCheckout" value="false" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <!-- 引用数据源 --> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="namingStrategy"> <bean class="org.hibernate.cfg.ImprovedNamingStrategy" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.format_sql">${hibernate.format_sql}</prop> <prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size} </prop> <prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size} </prop> </props> </property> <property name="packagesToScan" value="com.zw.domain" /> <!--</property> <property name="annotatedClasses"> <list> <value>org.wpms.kernel.user.po.User</value> </list> </property>--> </bean> <!-- 定义了与实体相关的dao --> <bean id="genericEntityDao" class="com.zw.core.GenericEntityDao" scope="prototype" lazy-init="true"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <!--使用泛型DAO作为抽象基类 abstract="true" --> <bean id="baseDao" class="com.zw.core.BaseDao" abstract="true" depends-on="genericEntityDao"> <property name="gedao"> <ref bean="genericEntityDao" /> </property> </bean> <!-- 使Spring关注Annotation --> <context:annotation-config /> <!-- 让Spring通过自动扫描来查询和管理Bean --> <context:component-scan base-package="com.zw" /> <!-- <bean id="toplMSoftDAO" class="com.zw.dao.ToplMSoftDAO" parent="baseDao"></bean> <bean id="toplMSoftServiceImpl" class="com.zw.service.impl.ToplMSoftServiceImpl"> <property name="toplMSoftDAO" ref="toplMSoftDAO" /> </bean> --> <!-- 业务类bean的实现类标注了@Transactional注解,所以会被 tx:annotation-driven注解驱动自动织入事务增强 --> <!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <!--注解式事务配置驱动--> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" /> </beans> [/code] ToplMSoft [code="java"] package com.zw.domain; import java.sql.Timestamp; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import static javax.persistence.GenerationType.IDENTITY; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name = "topl_m_soft", catalog = "zwtest") public class ToplMSoft implements java.io.Serializable { // Fields /** * */ private static final long serialVersionUID = -5245203859352468180L; private Integer softkey; private String softname; private String softtypekey; private String softversion; private String softsize; private String providername; private String providersite; private String downsite1; private String softfaceurl; private String issuestate; private String fruntime; private String sruntime; private Float marketprice; private Float storeprice; private String ifourcommend; private String ifspprice; private String softenglishname; private String runLink; private String runnum; private String downnum; private String column1; private String column2; private String column3; private String contact; private Timestamp createdate; private Timestamp updatedate; // Constructors /** default constructor */ public ToplMSoft() { } // Property accessors @Id @GeneratedValue(strategy = IDENTITY) @Column(name = "softkey", unique = true, nullable = false) public Integer getSoftkey() { return this.softkey; } public void setSoftkey(Integer softkey) { this.softkey = softkey; } @Column(name = "softname", nullable = false, length = 100) public String getSoftname() { return this.softname; } public void setSoftname(String softname) { this.softname = softname; } @Column(name = "softtypekey", nullable = false, length = 10) public String getSofttypekey() { return this.softtypekey; } public void setSofttypekey(String softtypekey) { this.softtypekey = softtypekey; } @Column(name = "softversion", length = 20) public String getSoftversion() { return this.softversion; } public void setSoftversion(String softversion) { this.softversion = softversion; } @Column(name = "softsize", length = 20) public String getSoftsize() { return this.softsize; } public void setSoftsize(String softsize) { this.softsize = softsize; } @Column(name = "providername", length = 200) public String getProvidername() { return this.providername; } public void setProvidername(String providername) { this.providername = providername; } @Column(name = "providersite", length = 100) public String getProvidersite() { return this.providersite; } public void setProvidersite(String providersite) { this.providersite = providersite; } @Column(name = "downsite1", length = 300) public String getDownsite1() { return this.downsite1; } public void setDownsite1(String downsite1) { this.downsite1 = downsite1; } @Column(name = "softfaceurl", length = 200) public String getSoftfaceurl() { return this.softfaceurl; } public void setSoftfaceurl(String softfaceurl) { this.softfaceurl = softfaceurl; } @Column(name = "issuestate", length = 10) public String getIssuestate() { return this.issuestate; } public void setIssuestate(String issuestate) { this.issuestate = issuestate; } @Column(name = "fruntime", length = 10) public String getFruntime() { return this.fruntime; } public void setFruntime(String fruntime) { this.fruntime = fruntime; } @Column(name = "sruntime", length = 10) public String getSruntime() { return this.sruntime; } public void setSruntime(String sruntime) { this.sruntime = sruntime; } @Column(name = "marketprice", precision = 10, scale = 0) public Float getMarketprice() { return this.marketprice; } public void setMarketprice(Float marketprice) { this.marketprice = marketprice; } @Column(name = "storeprice", precision = 10, scale = 0) public Float getStoreprice() { return this.storeprice; } public void setStoreprice(Float storeprice) { this.storeprice = storeprice; } @Column(name = "ifourcommend", length = 2) public String getIfourcommend() { return this.ifourcommend; } public void setIfourcommend(String ifourcommend) { this.ifourcommend = ifourcommend; } @Column(name = "ifspprice", length = 2) public String getIfspprice() { return this.ifspprice; } public void setIfspprice(String ifspprice) { this.ifspprice = ifspprice; } @Column(name = "softenglishname", length = 200) public String getSoftenglishname() { return this.softenglishname; } public void setSoftenglishname(String softenglishname) { this.softenglishname = softenglishname; } @Column(name = "runLink", length = 300) public String getRunLink() { return this.runLink; } public void setRunLink(String runLink) { this.runLink = runLink; } @Column(name = "runnum", length = 10) public String getRunnum() { return this.runnum; } public void setRunnum(String runnum) { this.runnum = runnum; } @Column(name = "downnum", length = 10) public String getDownnum() { return this.downnum; } public void setDownnum(String downnum) { this.downnum = downnum; } @Column(name = "column1", nullable = false, length = 2000) public String getColumn1() { return this.column1; } public void setColumn1(String column1) { this.column1 = column1; } @Column(name = "column2", length = 200) public String getColumn2() { return this.column2; } public void setColumn2(String column2) { this.column2 = column2; } @Column(name = "column3", length = 200) public String getColumn3() { return this.column3; } public void setColumn3(String column3) { this.column3 = column3; } @Column(name = "contact", length = 2) public String getContact() { return this.contact; } public void setContact(String contact) { this.contact = contact; } @Column(name = "createdate", length = 19) public Timestamp getCreatedate() { return this.createdate; } public void setCreatedate(Timestamp createdate) { this.createdate = createdate; } @Column(name = "updatedate", length = 19) public Timestamp getUpdatedate() { return this.updatedate; } public void setUpdatedate(Timestamp updatedate) { this.updatedate = updatedate; } } [/code] service 层 ToplMSoftService [code="java"] package com.zw.service; import com.zw.domain.ToplMSoft; public interface ToplMSoftService { public void save(ToplMSoft tps); } [/code] ToplMSoftServiceImpl [code="java"]package com.zw.service.impl; import javax.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import com.zw.core.BaseDao; import com.zw.core.IBaseDao; import com.zw.domain.ToplMSoft; import com.zw.service.ToplMSoftService; @Transactional(readOnly = true) //对业务类进行事务增强的标注 @Service //声明此类为业务逻辑层的类 public class ToplMSoftServiceImpl implements ToplMSoftService { @Resource(name ="toplMSoftDAO") private IBaseDao <ToplMSoft, Integer> toplMSoftDAO; public IBaseDao<ToplMSoft, Integer> getToplMSoftDAO() { return toplMSoftDAO; } public void setToplMSoftDAO(IBaseDao<ToplMSoft, Integer> toplMSoftDAO) { this.toplMSoftDAO = toplMSoftDAO; } @Transactional(readOnly = false, propagation = Propagation.REQUIRED) public void save(ToplMSoft tps) { System.out.println("toplMSoftDAO:"+toplMSoftDAO); this.toplMSoftDAO.save(tps); } } [/code] Test: [code="java"] package com.zw.test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.zw.domain.ToplMSoft; import com.zw.service.ToplMSoftService; import com.zw.service.impl.ToplMSoftServiceImpl; public class TestHibernate { public static void main(String[] args) { ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml"); ToplMSoftService dao= (ToplMSoftServiceImpl) ctx.getBean("toplMSoftServiceImpl"); //GenericEntityDao dao= (GenericEntityDao) ctx.getBean("ToplMSoftDAO"); System.out.println("1111111111:"+dao); ToplMSoft tps=new ToplMSoft(); tps.setSoftname("测试11111111"); tps.setSofttypekey("2"); tps.setColumn1("xsdasdasdasd"); dao.save(tps); } } [/code] 控制台输出 我在BaseDao save方法里面打出 System.out.println("gedao:"+gedao); 为null [code="java"] 1111111111:com.zw.service.impl.ToplMSoftServiceImpl@6e3e5e toplMSoftDAO:com.zw.dao.ToplMSoftDAO@10718b7 gedao:null Exception in thread "main" java.lang.NullPointerException at com.zw.core.BaseDao.save(BaseDao.java:60) at com.zw.service.impl.ToplMSoftServiceImpl.save(ToplMSoftServiceImpl.java:31) at com.zw.service.impl.ToplMSoftServiceImpl$$FastClassByCGLIB$$7aa0faa6.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191) at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625) at com.zw.service.impl.ToplMSoftServiceImpl$$EnhancerByCGLIB$$ded4983e.save(<generated>) at com.zw.test.TestHibernate.main(TestHibernate.java:22) [/code] 如果不用注解 直接在applicationContext.xml配置 [code="java"] <bean id="toplMSoftDAO" class="com.zw.dao.ToplMSoftDAO" parent="baseDao"></bean> <bean id="toplMSoftServiceImpl" class="com.zw.service.impl.ToplMSoftServiceImpl"> <property name="toplMSoftDAO" ref="toplMSoftDAO" /> </bean> [/code] 就不会报错 可以直接插入数据. 对Spring了解的不深 比较困惑 朋友们帮忙解答一下 谢谢
晕死,有人见过类似的错误没?关于的hibernate的
我没分了 5......... 先来错误提示(首先说明不是简单的表不存在,所有的映射文件都没有映射过company表[至少没有显式引用]) [code="java"]ERROR 2009-09-10 13:31:58.343 JDBCExceptionReporter:logExceptions - Table 'bfw_utf8.company' doesn't exist org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: could not insert: [com.bafang.pojos.SiteAd]; bad SQL grammar [insert into site_ad (subsite_id, site_ad_location_id, site_ad_location_name, site_ad_keyword_id, site_ad_keyword, company_id, company_name, txt, url, media_type, media_file, type, charge, start_time, end_time, item_order, enabled) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'bfw_utf8.company' doesn't exist Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'bfw_utf8.company' doesn't exist at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573) at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1160) at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:685) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1400) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1314) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1299) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105) at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2158) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2638) at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519) at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:598) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:358) at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:595) at com.bafang.pojos.base._BaseRootDAO.save(_BaseRootDAO.java:25) at com.bafang.pojos.base.BaseSiteAdDAO.save(BaseSiteAdDAO.java:20) at com.bafang.pojos.base.BaseSiteAdDAO$$FastClassByCGLIB$$33c630a7.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:609) at com.bafang.pojos.dao.SiteAdDAO$$EnhancerByCGLIB$$29bf5095.save(<generated>) at com.bafang.web.action.admin.main.AdAction.add(AdAction.java:107) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269) at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170) at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106) at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at com.bafang.web.servlet.BFActionServlet.process(BFActionServlet.java:26) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at com.bafang.web.filters.HTMLFilter.synthesisURI(HTMLFilter.java:85) at com.bafang.web.filters.HTMLFilter.doFilter(HTMLFilter.java:60) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at com.bafang.web.filters.AdminFilter.doFilter(AdminFilter.java:41) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at com.bafang.web.filters.SubsiteFilter.doFilter(SubsiteFilter.java:35) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Thread.java:619)[/code] 相关hibernate映射文件 SiteAd.hbm.xml [code="xml"]<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > <hibernate-mapping package="com.bafang.pojos"> <class name="SiteAd" table="site_ad"> <id name="id" type="integer" column="id"> <generator class="identity" /> </id> <property name="subsiteId" column="subsite_id" type="integer" not-null="false" length="11" /> <property name="siteAdLocationId" column="site_ad_location_id" type="string" not-null="false" length="50" /> <property name="siteAdLocationName" column="site_ad_location_name" type="string" not-null="false" length="255" /> <many-to-one name="siteAdLocation" column="site_ad_location_id" class="SiteAdLocation" not-null="false" insert="false" update="false" /> <property name="siteAdKeywordId" column="site_ad_keyword_id" type="integer" not-null="false" length="11" /> <property name="siteAdKeyword" column="site_ad_keyword" type="string" not-null="false" length="255" /> <property name="companyId" column="company_id" type="integer" not-null="false" length="11" /> <property name="companyName" column="company_name" type="string" not-null="false" length="255" /> <!--<many-to-one name="company" column="company_id" class="Store" not-null="false" insert="false" update="false" />--> <property name="txt" column="txt" type="string" not-null="false" length="255" /> <property name="url" column="url" type="string" not-null="false" length="255" /> <property name="mediaType" column="media_type" type="string" not-null="false" length="255" /> <property name="mediaFile" column="media_file" type="string" not-null="false" length="255" /> <property name="type" column="type" type="string" not-null="false" length="100" /> <property name="charge" column="charge" type="java.lang.Float" not-null="false" length="12" /> <property name="startTime" column="start_time" type="timestamp" not-null="false" length="19" /> <property name="endTime" column="end_time" type="timestamp" not-null="false" length="19" /> <property name="itemOrder" column="item_order" type="integer" not-null="false" length="11" /> <property name="enabled" column="enabled" type="boolean" not-null="false" length="1" /> </class> </hibernate-mapping>[/code] pojo相关类 com.bafang.pojos.SiteAd.java [code="java"]package com.bafang.pojos; import com.bafang.pojos.base.BaseSiteAd; public class SiteAd extends BaseSiteAd { private static final long serialVersionUID = 7092206885096359130L; public SiteAd () { } public String getTypeName(){ if("1".equals(getType())) return "多媒体广告"; else if("2".equals(getType())) return "连接广告"; else if("3".equals(getType())) return "店铺广告"; else if("4".equals(getType())) return "店铺评论广告"; else return "其它广告"; } }[/code] com.bafang.pojos.base.BaseSiteAd.java [code="java"]package com.bafang.pojos.base; import java.io.Serializable; public abstract class BaseSiteAd implements Serializable { protected Integer id; protected Integer subsiteId; protected String siteAdLocationId; protected String siteAdLocationName; protected Integer siteAdKeywordId; protected String siteAdKeyword; protected Integer companyId; protected String companyName; protected String txt; protected String url; protected String mediaType; protected String mediaFile; protected String type; protected Float charge; protected java.util.Date startTime; protected java.util.Date endTime; protected Integer itemOrder; protected Boolean enabled; protected com.bafang.pojos.SiteAdLocation siteAdLocation; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Integer getSubsiteId() { return subsiteId; } public void setSubsiteId(Integer subsiteId) { this.subsiteId = subsiteId; } public String getSiteAdLocationId() { return siteAdLocationId; } public void setSiteAdLocationId(String siteAdLocationId) { this.siteAdLocationId = siteAdLocationId; } public String getSiteAdLocationName() { return siteAdLocationName; } public void setSiteAdLocationName(String siteAdLocationName) { this.siteAdLocationName = siteAdLocationName; } public Integer getSiteAdKeywordId() { return siteAdKeywordId; } public void setSiteAdKeywordId(Integer siteAdKeywordId) { this.siteAdKeywordId = siteAdKeywordId; } public String getSiteAdKeyword() { return siteAdKeyword; } public void setSiteAdKeyword(String siteAdKeyword) { this.siteAdKeyword = siteAdKeyword; } public Integer getCompanyId() { return companyId; } public void setCompanyId(Integer companyId) { this.companyId = companyId; } public String getCompanyName() { return companyName; } public void setCompanyName(String companyName) { this.companyName = companyName; } public String getTxt() { return txt; } public void setTxt(String txt) { this.txt = txt; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public String getMediaType() { return mediaType; } public void setMediaType(String mediaType) { this.mediaType = mediaType; } public String getMediaFile() { return mediaFile; } public void setMediaFile(String mediaFile) { this.mediaFile = mediaFile; } public String getType() { return type; } public void setType(String type) { this.type = type; } public Float getCharge() { return charge; } public void setCharge(Float charge) { this.charge = charge; } public java.util.Date getStartTime() { return startTime; } public void setStartTime(java.util.Date startTime) { this.startTime = startTime; } public java.util.Date getEndTime() { return endTime; } public void setEndTime(java.util.Date endTime) { this.endTime = endTime; } public Integer getItemOrder() { return itemOrder; } public void setItemOrder(Integer itemOrder) { this.itemOrder = itemOrder; } public Boolean getEnabled() { return enabled; } public void setEnabled(Boolean enabled) { this.enabled = enabled; } public com.bafang.pojos.SiteAdLocation getSiteAdLocation() { return siteAdLocation; } public void setSiteAdLocation(com.bafang.pojos.SiteAdLocation siteAdLocation) { this.siteAdLocation = siteAdLocation; } }[/code] 保存动作是直接调用spring的工具类 org.springframework.orm.hibernate3.support.HibernateDaoSupport.save(Object obj); 我debug过,就是保存的动作后报的错 数据库query 日志 [code="java"]090910 13:31:50 2 Query SET autocommit=0 2 Prepare select siteadloca0_.id as id17_, siteadloca0_.subsite_id as subsite2_17_, siteadloca0_.name as name17_, siteadloca0_.type as type17_, siteadloca0_.width as width17_, siteadloca0_.height as height17_, siteadloca0_.item_count as item7_17_, siteadloca0_.url as url17_, siteadloca0_.enabled as enabled17_ from site_ad_location siteadloca0_ where 1=1 and siteadloca0_.subsite_id=1 limit ? 2 Execute select siteadloca0_.id as id17_, siteadloca0_.subsite_id as subsite2_17_, siteadloca0_.name as name17_, siteadloca0_.type as type17_, siteadloca0_.width as width17_, siteadloca0_.height as height17_, siteadloca0_.item_count as item7_17_, siteadloca0_.url as url17_, siteadloca0_.enabled as enabled17_ from site_ad_location siteadloca0_ where 1=1 and siteadloca0_.subsite_id=1 limit 20 2 Close stmt 2 Query commit 2 Query SET autocommit=1 2 Query SET autocommit=0 2 Prepare select count(*) as col_0_0_ from site_ad_location siteadloca0_ where 1=1 and siteadloca0_.subsite_id=? 2 Execute select count(*) as col_0_0_ from site_ad_location siteadloca0_ where 1=1 and siteadloca0_.subsite_id=1 2 Close stmt 2 Query commit 2 Query SET autocommit=1 090910 13:31:58 2 Prepare insert into site_ad (subsite_id, site_ad_location_id, site_ad_location_name, site_ad_keyword_id, site_ad_keyword, company_id, company_name, txt, url, media_type, media_file, type, charge, start_time, end_time, item_order, enabled) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 2 Query select name into str from site_ad_location where id=new.site_ad_location_id 2 Query select name into str from company where id=new.company_id 2 Query SELECT 1 2 Close stmt D:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld, Version: 5.1.37-community-log (MySQL Community Server (GPL)). started with: TCP Port: 3306, Named Pipe: (null) Time Id Command Argument 090910 13:33:15 1 Connect root@localhost on 1 Query SET NAMES utf8 2 Connect root@localhost on 2 Query SELECT @@sql_mode 2 Query SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' 2 Query SET NAMES utf8 2 Quit 090910 13:33:17 1 Quit 3 Connect root@localhost on 3 Query SELECT @@sql_mode 3 Query SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' 3 Query SET NAMES utf8[/code] [b]问题补充:[/b] [quote]dwangel[/quote]已经清理过项目 还是一样 谢谢啊 已经找到问题了 以前写成的程序员 弄了个触发器在数据库里 刚刚发现的 谢谢了 分不多都给你了
springmvc配置表单校验jar包依赖报错
我最近在配置springmvc校验的时候出现了问题,我猜测主要是依赖的问题希望大家帮帮忙。接下来我贴出我的配置 tomcat8+jdk8+spring版本4.3.3.RELEASE 最重要的部分引入校验依赖 ``` <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>5.2.2.Final</version> </dependency> <!-- 在校验文件中使用el表达式 --> <dependency> <groupId>javax.el</groupId> <artifactId>javax.el-api</artifactId> <version>2.2.4</version> <scope>provided</scope> </dependency> ``` ![图片说明](https://img-ask.csdn.net/upload/201612/18/1482041265_781261.png) 下面是springmvc.xml里面的配置(其实这个配置应该是没有错的,因为这个配置就算没有报的错也是一样的) ``` <!-- spring mvc验证开始 ,若不使用这种配置,需要将错误信息硬编码到代码里,不易修改--> <!-- 以下 validator ConversionService 在使用 mvc:annotation-driven 会 自动注册--> <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"> <property name="providerClass" value="org.hibernate.validator.HibernateValidator"/> <!-- 如果不加默认到 使用classpath下的 ValidationMessages.properties --> <property name="validationMessageSource" ref="messageSource"/> </bean> <!-- 国际化的消息资源文件(本系统中主要用于显示/错误消息定制) --> <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basenames"> <list> <!-- 在web环境中一定要定位到classpath 否则默认到当前web应用下找 --> <value>classpath:validation.properties</value> <value>classpath:org/hibernate/validator/ValidationMessages</value> </list> </property> <property name="useCodeAsDefaultMessage" value="false"/> <property name="defaultEncoding" value="UTF-8"/> <property name="cacheSeconds" value="60"/> </bean> <!-- spring mvc验证结束 --> ``` 接下来是报错信息(我给剪切到一行了) 这里是主要信息 ``` Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#132070ce': Cannot resolve reference to bean 'validator' while setting bean property 'validator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'validator' defined in URL [file:/E:/Workspaces/Web%20Templet/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/web_homework/WEB-INF/classes/springmvc.xml]: Invocation of init method failed; nested exception is java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/Persistence ``` 这里是详细的错误信息 ``` org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/Persistence at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:751) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1227) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1140) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1027) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5038) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5348) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397) 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: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/Persistence at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2558) at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:859) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1302) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.hibernate.validator.internal.util.privilegedactions.LoadClass.loadNonValidatorClass(LoadClass.java:103) at org.hibernate.validator.internal.util.privilegedactions.LoadClass.run(LoadClass.java:64) at org.hibernate.validator.internal.util.privilegedactions.LoadClass.run(LoadClass.java:29) at org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver.run(DefaultTraversableResolver.java:147) at org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver.detectJPA(DefaultTraversableResolver.java:67) at org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver.<init>(DefaultTraversableResolver.java:57) at org.hibernate.validator.internal.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:126) at org.hibernate.validator.internal.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:96) at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:31) at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:276) at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:248) at org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean.afterPropertiesSet(OptionalValidatorFactoryBean.java:40) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1642) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579) ... 28 more ``` 希望大家帮帮忙,查询了很多网上的解决办法但是我的配置都和他们说的是一样的但是就是存在这样的问题,自己的能力实在解决不了。只能猜测是jar包依赖的问题但是包又都是全的,所以没有拌饭解决了。
终于明白阿里百度这样的大公司,为什么面试经常拿ThreadLocal考验求职者了
点击上面↑「爱开发」关注我们每晚10点,捕获技术思考和创业资源洞察什么是ThreadLocalThreadLocal是一个本地线程副本变量工具类,各个线程都拥有一份线程私有的数
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
此博客仅为我业余记录文章所用,发布到此,仅供网友阅读参考,如有侵权,请通知我,我会删掉。 补充 有不少读者留言说本文章没有用,因为天气预报直接打开手机就可以收到了,为何要多此一举发送到邮箱呢!!!那我在这里只能说:因为你没用,所以你没用!!! 这里主要介绍的是思路,不是天气预报!不是天气预报!!不是天气预报!!!天气预报只是用于举例。请各位不要再刚了!!! 下面是我会用到的两个场景: 每日下
面试官问我:什么是消息队列?什么场景需要他?用了会出现什么问题?
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图、个人联系方式,欢迎Star和完善 前言 消息队列在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在消息队列的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸,打败了无数
8年经验面试官详解 Java 面试秘诀
    作者 | 胡书敏 责编 | 刘静 出品 | CSDN(ID:CSDNnews) 本人目前在一家知名外企担任架构师,而且最近八年来,在多家外企和互联网公司担任Java技术面试官,前后累计面试了有两三百位候选人。在本文里,就将结合本人的面试经验,针对Java初学者、Java初级开发和Java开发,给出若干准备简历和准备面试的建议。   Java程序员准备和投递简历的实
究竟你适不适合买Mac?
我清晰的记得,刚买的macbook pro回到家,开机后第一件事情,就是上了淘宝网,花了500元钱,找了一个上门维修电脑的师傅,上门给我装了一个windows系统。。。。。。 表砍我。。。 当时买mac的初衷,只是想要个固态硬盘的笔记本,用来运行一些复杂的扑克软件。而看了当时所有的SSD笔记本后,最终决定,还是买个好(xiong)看(da)的。 已经有好几个朋友问我mba怎么样了,所以今天尽量客观
MyBatis研习录(01)——MyBatis概述与入门
C语言自学完备手册(33篇) Android多分辨率适配框架 JavaWeb核心技术系列教程 HTML5前端开发实战系列教程 MySQL数据库实操教程(35篇图文版) 推翻自己和过往——自定义View系列教程(10篇) 走出思维困境,踏上精进之路——Android开发进阶精华录 讲给Android程序员看的前端系列教程(40集免费视频教程+源码) 版权声明 本文原创作者:谷哥的小弟 作者博客
程序员一般通过什么途径接私活?
二哥,你好,我想知道一般程序猿都如何接私活,我也想接,能告诉我一些方法吗? 上面是一个读者“烦不烦”问我的一个问题。其实不止是“烦不烦”,还有很多读者问过我类似这样的问题。 我接的私活不算多,挣到的钱也没有多少,加起来不到 20W。说实话,这个数目说出来我是有点心虚的,毕竟太少了,大家轻喷。但我想,恰好配得上“一般程序员”这个称号啊。毕竟苍蝇再小也是肉,我也算是有经验的人了。 唾弃接私活、做外
Python爬虫爬取淘宝,京东商品信息
小编是一个理科生,不善长说一些废话。简单介绍下原理然后直接上代码。 使用的工具(Python+pycharm2019.3+selenium+xpath+chromedriver)其中要使用pycharm也可以私聊我selenium是一个框架可以通过pip下载 pip install selenium -i https://pypi.tuna.tsinghua.edu.cn/simple/ 
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
你知道的越多,你不知道的越多 点赞再看,养成习惯 本文 GitHub https://github.com/JavaFamily 已收录,有一线大厂面试点思维导图,也整理了很多我的文档,欢迎Star和完善,大家面试可以参照考点复习,希望我们一起有点东西。 前前言 为啥今天有个前前言呢? 因为你们的丙丙啊,昨天有牌面了哟,直接被微信官方推荐,知乎推荐,也就仅仅是还行吧(心里乐开花)
Java工作4年来应聘要16K最后没要,细节如下。。。
前奏: 今天2B哥和大家分享一位前几天面试的一位应聘者,工作4年26岁,统招本科。 以下就是他的简历和面试情况。 基本情况: 专业技能: 1、&nbsp;熟悉Sping了解SpringMVC、SpringBoot、Mybatis等框架、了解SpringCloud微服务 2、&nbsp;熟悉常用项目管理工具:SVN、GIT、MAVEN、Jenkins 3、&nbsp;熟悉Nginx、tomca
Python爬虫精简步骤1 获取数据
爬虫的工作分为四步: 1.获取数据。爬虫程序会根据我们提供的网址,向服务器发起请求,然后返回数据。 2.解析数据。爬虫程序会把服务器返回的数据解析成我们能读懂的格式。 3.提取数据。爬虫程序再从中提取出我们需要的数据。 4.储存数据。爬虫程序把这些有用的数据保存起来,便于你日后的使用和分析。 这一篇的内容就是:获取数据。 首先,我们将会利用一个强大的库——requests来获取数据。 在电脑上安装
Python绘图,圣诞树,花,爱心 | Turtle篇
1.画圣诞树 import turtle screen = turtle.Screen() screen.setup(800,600) circle = turtle.Turtle() circle.shape('circle') circle.color('red') circle.speed('fastest') circle.up() square = turtle.Turtle()
作为一个程序员,CPU的这些硬核知识你必须会!
CPU对每个程序员来说,是个既熟悉又陌生的东西? 如果你只知道CPU是中央处理器的话,那可能对你并没有什么用,那么作为程序员的我们,必须要搞懂的就是CPU这家伙是如何运行的,尤其要搞懂它里面的寄存器是怎么一回事,因为这将让你从底层明白程序的运行机制。 随我一起,来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说,我们首先就要搞明白它是怎么回事,也就是它的内部构造,当然,CPU那么牛的一个东
破14亿,Python分析我国存在哪些人口危机!
2020年1月17日,国家统计局发布了2019年国民经济报告,报告中指出我国人口突破14亿。 猪哥的朋友圈被14亿人口刷屏,但是很多人并没有看到我国复杂的人口问题:老龄化、男女比例失衡、生育率下降、人口红利下降等。 今天我们就来分析一下我们国家的人口数据吧! 更多有趣分析教程,扫描下方二维码关注vx公号「裸睡的猪」 即可查看! 一、背景 1.人口突破14亿 2020年1月17日,国家统计局发布
web前端javascript+jquery知识点总结
Javascript javascript 在前端网页中占有非常重要的地位,可以用于验证表单,制作特效等功能,它是一种描述语言,也是一种基于对象(Object)和事件驱动并具有安全性的脚本语言 ,语法同java类似,是一种解释性语言,边执行边解释。 JavaScript的组成: ECMAScipt 用于描述: 语法,变量和数据类型,运算符,逻辑控制语句,关键字保留字,对象。 浏览器对象模型(Br
Python实战:抓肺炎疫情实时数据,画2019-nCoV疫情地图
文章目录1. 前言2. 数据下载3. 数据处理4. 数据可视化 1. 前言 今天,群里白垩老师问如何用python画武汉肺炎疫情地图。白垩老师是研究海洋生态与地球生物的学者,国家重点实验室成员,于不惑之年学习python,实为我等学习楷模。先前我并没有关注武汉肺炎的具体数据,也没有画过类似的数据分布图。于是就拿了两个小时,专门研究了一下,遂成此文。 2月6日追记:本文发布后,腾讯的数据源多次变更u
听说想当黑客的都玩过这个Monyer游戏(1~14攻略)
第零关 进入传送门开始第0关(游戏链接) 请点击链接进入第1关: 连接在左边→ ←连接在右边 看不到啊。。。。(只能看到一堆大佬做完的留名,也能看到菜鸡的我,在后面~~) 直接fn+f12吧 &lt;span&gt;连接在左边→&lt;/span&gt; &lt;a href="first.php"&gt;&lt;/a&gt; &lt;span&gt;←连接在右边&lt;/span&gt; o
在家远程办公效率低?那你一定要收好这个「在家办公」神器!
相信大家都已经收到国务院延长春节假期的消息,接下来,在家远程办公可能将会持续一段时间。 但是问题来了。远程办公不是人在电脑前就当坐班了,相反,对于沟通效率,文件协作,以及信息安全都有着极高的要求。有着非常多的挑战,比如: 1在异地互相不见面的会议上,如何提高沟通效率? 2文件之间的来往反馈如何做到及时性?如何保证信息安全? 3如何规划安排每天工作,以及如何进行成果验收? ......
作为一个程序员,内存和磁盘的这些事情,你不得不知道啊!!!
截止目前,我已经分享了如下几篇文章: 一个程序在计算机中是如何运行的?超级干货!!! 作为一个程序员,CPU的这些硬核知识你必须会! 作为一个程序员,内存的这些硬核知识你必须懂! 这些知识可以说是我们之前都不太重视的基础知识,可能大家在上大学的时候都学习过了,但是嘞,当时由于老师讲解的没那么有趣,又加上这些知识本身就比较枯燥,所以嘞,大家当初几乎等于没学。 再说啦,学习这些,也看不出来有什么用啊!
渗透测试-灰鸽子远控木马
木马概述 灰鸽子( Huigezi),原本该软件适用于公司和家庭管理,其功能十分强大,不但能监视摄像头、键盘记录、监控桌面、文件操作等。还提供了黑客专用功能,如:伪装系统图标、随意更换启动项名称和表述、随意更换端口、运行后自删除、毫无提示安装等,并采用反弹链接这种缺陷设计,使得使用者拥有最高权限,一经破解即无法控制。最终导致被黑客恶意使用。原作者的灰鸽子被定义为是一款集多种控制方式于一体的木马程序
Python:爬取疫情每日数据
前言 有部分同学留言说为什么412,这是因为我代码里全国的cookies需要你自己打开浏览器更新好后替换,而且这个cookies大概只能持续20秒左右! 另外全国卫健委的数据格式一直在变,也有可能会导致爬取失败! 我现在已根据2月14日最新通报稿的格式修正了! 目前每天各大平台,如腾讯、今日头条都会更新疫情每日数据,他们的数据源都是一样的,主要都是通过各地的卫健委官网通报。 为什么已经有大量平台做
这个世界上人真的分三六九等,你信吗?
偶然间,在知乎上看到一个问题 一时间,勾起了我深深的回忆。 以前在厂里打过两次工,做过家教,干过辅导班,做过中介。零下几度的晚上,贴过广告,满脸、满手地长冻疮。   再回首那段岁月,虽然苦,但让我学会了坚持和忍耐。让我明白了,在这个世界上,无论环境多么的恶劣,只要心存希望,星星之火,亦可燎原。   下文是原回答,希望能对你能有所启发。   如果我说,这个世界上人真的分三六九等,
B 站上有哪些很好的学习资源?
哇说起B站,在小九眼里就是宝藏般的存在,放年假宅在家时一天刷6、7个小时不在话下,更别提今年的跨年晚会,我简直是跪着看完的!! 最早大家聚在在B站是为了追番,再后来我在上面刷欧美新歌和漂亮小姐姐的舞蹈视频,最近两年我和周围的朋友们已经把B站当作学习教室了,而且学习成本还免费,真是个励志的好平台ヽ(.◕ฺˇд ˇ◕ฺ;)ノ 下面我们就来盘点一下B站上优质的学习资源: 综合类 Oeasy: 综合
雷火神山直播超两亿,Web播放器事件监听是怎么实现的?
Web播放器解决了在手机浏览器和PC浏览器上播放音视频数据的问题,让视音频内容可以不依赖用户安装App,就能进行播放以及在社交平台进行传播。在视频业务大数据平台中,播放数据的统计分析非常重要,所以Web播放器在使用过程中,需要对其内部的数据进行收集并上报至服务端,此时,就需要对发生在其内部的一些播放行为进行事件监听。 那么Web播放器事件监听是怎么实现的呢? 01 监听事件明细表 名
3万字总结,Mysql优化之精髓
本文知识点较多,篇幅较长,请耐心学习 MySQL已经成为时下关系型数据库产品的中坚力量,备受互联网大厂的青睐,出门面试想进BAT,想拿高工资,不会点MySQL优化知识,拿offer的成功率会大大下降。 为什么要优化 系统的吞吐量瓶颈往往出现在数据库的访问速度上 随着应用程序的运行,数据库的中的数据会越来越多,处理时间会相应变慢 数据是存放在磁盘上的,读写速度无法和内存相比 如何优化 设计
Python新型冠状病毒疫情数据自动爬取+统计+发送报告+数据屏幕(三)发送篇
今天介绍的项目是使用 Itchat 发送统计报告 项目功能设计: 定时爬取疫情数据存入Mysql 进行数据分析制作疫情报告 使用itchat给亲人朋友发送分析报告(本文) 基于Django做数据屏幕 使用Tableau做数据分析 来看看最终效果 目前已经完成,预计2月12日前更新 使用 itchat 发送数据统计报告 itchat 是一个基于 web微信的一个框架,但微信官方并不允
作为程序员的我,大学四年一直自学,全靠这些实用工具和学习网站!
我本人因为高中沉迷于爱情,导致学业荒废,后来高考,毫无疑问进入了一所普普通通的大学,实在惭愧...... 我又是那么好强,现在学历不行,没办法改变的事情了,所以,进入大学开始,我就下定决心,一定要让自己掌握更多的技能,尤其选择了计算机这个行业,一定要多学习技术。 在进入大学学习不久后,我就认清了一个现实:我这个大学的整体教学质量和学习风气,真的一言难尽,懂的人自然知道怎么回事? 怎么办?我该如何更好的提升
粒子群算法求解物流配送路线问题(python)
粒子群算法求解物流配送路线问题(python) 1.查找论文文献 找一篇物流配送路径优化+粒子群算法求解的论文 参考文献:基于混沌粒子群算法的物流配送路径优化 2.了解粒子群算法的原理 讲解通俗易懂,有数学实例的博文:https://blog.csdn.net/daaikuaichuan/article/details/81382794 3.确定编码方式和解码策略 3.1编码方式 物流配送路线的
教你如何编写第一个简单的爬虫
很多人知道爬虫,也很想利用爬虫去爬取自己想要的数据,那么爬虫到底怎么用呢?今天就教大家编写一个简单的爬虫。 下面以爬取笔者的个人博客网站为例获取第一篇文章的标题名称,教大家学会一个简单的爬虫。 第一步:获取页面 #!/usr/bin/python # coding: utf-8 import requests #引入包requests link = "http://www.santostang.
前端JS初级面试题二 (。•ˇ‸ˇ•。)老铁们!快来瞧瞧自己都会了么
1. 传统事件绑定和符合W3C标准的事件绑定有什么区别? 传统事件绑定 &lt;div onclick=""&gt;123&lt;/div&gt; div1.onclick = function(){}; &lt;button onmouseover=""&gt;&lt;/button&gt; 注意: 如果给同一个元素绑定了两次或多次相同类型的事件,那么后面的绑定会覆盖前面的绑定 (不支持DOM事...
相关热词 c# 时间比天数 c# oracle查询 c# 主动推送 事件 c# java 属性 c# 控制台 窗体 c# 静态类存值 c#矢量作图 c#窗体调用外部程式 c# enum是否合法 c# 如何卸载引用
立即提问