how2j.cn

下载区
文件名 文件大小
struts2-convention-plugin-2.1.7.jar 64k
ssh.rar 16m

工具版本兼容问题
以注解的方式,来进行SSH整合配置


步骤 1 : 先运行,看到效果,再学习   
步骤 2 : 模仿和排错   
步骤 3 : 基于前面的教程   
步骤 4 : jar   
步骤 5 : 修改applicationContext.xml   
步骤 6 : 修改struts.xml   
步骤 7 : 为ProductAction添加注解   
步骤 8 : 为ProductServiceImpl 添加注解   
步骤 9 : 为ProductDAOImpl 添加注解   
步骤 10 : 为Product添加注解   
步骤 11 : 重启测试   

步骤 1 :

先运行,看到效果,再学习

edit
老规矩,先下载右上角的可运行项目,配置运行起来,确认可用之后,再学习做了哪些步骤以达到这样的效果。

访问地址:

http://127.0.0.1:8080/ssh/listProduct
在确保可运行项目能够正确无误地运行之后,再严格照着教程的步骤,对代码模仿一遍。
模仿过程难免代码有出入,导致无法得到期望的运行结果,此时此刻通过比较正确答案 ( 可运行项目 ) 和自己的代码,来定位问题所在。
采用这种方式,学习有效果,排错有效率,可以较为明显地提升学习速度,跨过学习路上的各个槛。

推荐使用diffmerge软件,进行文件夹比较。把你自己做的项目文件夹,和我的可运行项目文件夹进行比较。
这个软件很牛逼的,可以知道文件夹里哪两个文件不对,并且很明显地标记出来
这里提供了绿色安装和使用教程:diffmerge 下载和使用教程
步骤 3 :

基于前面的教程

edit
本章节延续上面的SSH 事务管理注解方式继续,这样的好处是目前的状态,除了事务以外,其他都是XML配置方式。 大家就可以看到如何从XML配置方式转换为注解方式,并最后达到一样的效果。
对比起来学习,更加容易理解
1. 为了使struts支持注解,需要用到struts2-convention-plugin-x.x.x.jar 这个jar包,在前面的教程中是没有使用的,所以这里需要从右侧下载

2. 从右上角下载好了之后,放在WEB-INF/lib 下

3. 不仅如此,还要在项目导入jar,以使得eclipse能够编译通过
步骤 5 :

修改applicationContext.xml

edit
1. 增加注解配置,组建扫描,以及移动事务管理的配置到前面

<context:annotation-config />
<context:component-scan base-package="com.how2java" />
<tx:annotation-driven transaction-manager="transactionManager"/>

2. 注释掉 action,service,dao
3. 替换SessionFactory类

org.springframework.orm.hibernate3.LocalSessionFactoryBean



org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

以支持注解方式
4. 去掉

<property name="mappingResources">
<list>
<value>com/how2java/pojo/Product.hbm.xml</value>
</list>
</property>

增加

<property name="packagesToScan">
<list>
<value>com.how2java.*</value>
</list>
</property>


参考: Spring 注解方式
<?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:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:annotation-config /> <context:component-scan base-package="com.how2java" /> <tx:annotation-driven transaction-manager="transactionManager"/> <!-- <bean name="productActionBean" class="com.how2java.action.ProductAction"> --> <!-- <property name="productService" ref="productServiceImpl" /> --> <!-- </bean> --> <!-- <bean name="productServiceImpl" class="com.how2java.service.impl.ProductServiceImpl"> --> <!-- <property name="productDAO" ref="productDAOImpl" /> --> <!-- </bean> --> <!-- <bean name="productDAOImpl" class="com.how2java.dao.impl.ProductDAOImpl"> --> <!-- <property name="sessionFactory" ref="sf" /> --> <!-- </bean> --> <bean name="sf" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="ds" /> <!-- <property name="mappingResources"> --> <!-- <list> --> <!-- <value>com/how2java/pojo/Product.hbm.xml</value> --> <!-- </list> --> <!-- </property> --> <!-- 注解扫描 --> <property name="packagesToScan"> <list> <value>com.how2java.*</value> </list> </property> <property name="schemaUpdate"> <value>true</value> </property> <property name="hibernateProperties"> <value> hibernate.dialect=org.hibernate.dialect.MySQLDialect hibernate.show_sql=true hbm2ddl.auto=update </value> </property> </bean> <bean name="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/how2java?characterEncoding=UTF-8" /> <property name="username" value="root" /> <property name="password" value="admin" /> </bean> <!-- 配置事务管理器(声明式的事务) --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sf"></property> </bean> </beans>
注释掉action配置
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.i18n.encoding" value="UTF-8"></constant> <constant name="struts.objectFactory" value="spring"/> <package name="basicstruts" extends="struts-default"> <!-- <action name="listProduct" class="productActionBean" method="list"> --> <!-- <result name="listJsp">list.jsp</result> --> <!-- </action> --> </package> </struts>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
  <constant name="struts.i18n.encoding" value="UTF-8"></constant>
  
  <constant name="struts.objectFactory" value="spring"/>
  
  <package name="basicstruts" extends="struts-default">
  
<!--   <action name="listProduct" class="productActionBean" method="list"> -->
<!--     <result name="listJsp">list.jsp</result> -->
<!--   </action> -->
  
</package>
</struts>
步骤 7 :

为ProductAction添加注解

edit
1. 配置Namespace,ParentPackage,Results

@Namespace("/")
@ParentPackage("struts-default")
@Results({@Result(name="listJsp", location="/list.jsp")})

2. 使用@Autowired自动装配productService
3. 在list()方法前加注解 @Action("listProduct"),以映射路径

参考:Struts 注解方式
package com.how2java.action; import java.util.List; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.ParentPackage; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.springframework.beans.factory.annotation.Autowired; import com.how2java.pojo.Product; import com.how2java.service.ProductService; @Namespace("/") @ParentPackage("struts-default") @Results({@Result(name="listJsp", location="/list.jsp")}) public class ProductAction { @Autowired ProductService productService; List<Product> products; @Action("listProduct") public String list() { products = productService.list(); return "listJsp"; } public ProductService getProductService() { return productService; } public void setProductService(ProductService productService) { this.productService = productService; } public List<Product> getProducts() { return products; } public void setProducts(List<Product> products) { this.products = products; } }
步骤 8 :

为ProductServiceImpl 添加注解

edit
1. 使用@Service 为 ProductServiceImpl添加注解
2. 使用@Autowired自动装配productDAO
3. 注释掉故意抛出异常部分
// if(i==2)
// throw new RuntimeException();
package com.how2java.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import com.how2java.dao.ProductDAO; import com.how2java.pojo.Product; import com.how2java.service.ProductService; @Service public class ProductServiceImpl implements ProductService { @Autowired ProductDAO productDAO; @Transactional(propagation=Propagation.REQUIRED,rollbackForClassName="Exception") public List<Product> list() { List<Product> products= productDAO.list(); if(products.isEmpty()){ for (int i = 0; i < 5; i++) { Product p = new Product(); p.setName("product " + i); productDAO.add(p); products.add(p); } } return products; } public ProductDAO getProductDAO() { return productDAO; } public void setProductDAO(ProductDAO productDAO) { this.productDAO = productDAO; } }
步骤 9 :

为ProductDAOImpl 添加注解

edit
1. 使用Repository 为ProductDAOImpl 添加注解
2. 重写setSessionFactory方法,并使用@Resource(name="sf")对其注解,以接受sessionFactory注入( 在 applicationContext.xml中sessionFactory所取得id是sf)
为什么要重写?
虽然ProductDAOImpl 继承了HibernateTemplate ,有setSessionFactory方法,但是HibernateTemplate 中的setSessionFactory方法,并没有被注解,所以就不会被注入sf, 因此需要在这里重写这个方法。
package com.how2java.dao.impl; import java.util.List; import javax.annotation.Resource; import org.hibernate.SessionFactory; import org.springframework.orm.hibernate3.HibernateTemplate; import org.springframework.stereotype.Repository; import com.how2java.dao.ProductDAO; import com.how2java.pojo.Product; @Repository("productDAO") public class ProductDAOImpl extends HibernateTemplate implements ProductDAO{ @Resource(name="sf") public void setSessionFactory(SessionFactory sessionFactory) { super.setSessionFactory(sessionFactory); }; public List<Product> list() { return find("from Product"); } @Override public void add(Product p) { save(p); } }
步骤 10 :

为Product添加注解

edit
1. 使用@Entity 为 Product 添加注解
2. @Table 指定对应表名
3. @id 表明主键
4. @GeneratedValue(strategy = GenerationType.IDENTITY) 使用自增长策略
5. @Column 指明属性对应的数据库中的字段名

参考: Hibernate 注解方式
package com.how2java.pojo; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name = "product_") public class Product { int id; String name; float price; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") public int getId() { return id; } public void setId(int id) { this.id = id; } @Column(name = "name") public String getName() { return name; } public void setName(String name) { this.name = name; } @Column(name = "price") public float getPrice() { return price; } public void setPrice(float price) { this.price = price; } }
重启后,访问地址

http://127.0.0.1:8080/ssh/listProduct
重启测试


HOW2J公众号,关注后实时获知布最新的教程和优惠活动,谢谢。


问答区域    
2019-03-30 越界错误
how2jcxp



idea。启动tomcat,发生错误,BeanDefinitionException.是不是有可能和版本有关系啊。 原来ProductServiceImpl类导入javax.annotation.Resource无法识别,我就右键单击下载了6个包,可以识别了,但是出现了上述错误。具体见截图 站长可以解答一下嘛
package com.how2java.dao.impl;

import java.util.List;
import javax.annotation.Resource;//此处原未能识别

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;
import com.how2java.dao.ProductDao;
import com.how2java.pojo.Product;
@Repository("ProductDao")
public class ProductDaoImpl extends HibernateTemplate implements ProductDao{
    @Resource(name="sf")//此处原未能识别,右键直接下载6个包后可以识别
    public void setSessionFactory(SessionFactory sf){super.setSessionFactory(sf);}
    public List<Product> list() {
        System.out.println(this);
        return find("from Product");
    }

    @Override
    public void add(Product p) {
        save(p);
    }

}
30-Mar-2019 18:11:31.383 信息 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
30-Mar-2019 18:11:31.781 信息 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
30-Mar-2019 18:11:32.868 严重 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStart 异常将上下文初始化事件发送到类的侦听器实例.[org.springframework.web.context.ContextLoaderListener]
 org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [C:\Java\workingplace\ssh\out\artifacts\ssh_war_exploded\WEB-INF\classes\com\how2java\service\impl\ProductServiceImpl.class]; nested exception is java.lang.ArrayIndexOutOfBoundsException: Index 27137 out of bounds for length 107
	at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:261)
	at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)
	at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)
	at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1431)
	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1421)
	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:527)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:441)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4668)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5136)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1729)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289)
	at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809)
	at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:457)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:406)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289)
	at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809)
	at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466)
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307)
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399)
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 27137 out of bounds for length 107
	at org.springframework.asm.ClassReader.readClass(Unknown Source)
	at org.springframework.asm.ClassReader.accept(Unknown Source)
	at org.springframework.asm.ClassReader.accept(Unknown Source)
	at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:54)
	at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
	at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:101)
	at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:237)
	... 67 more

30-Mar-2019 18:11:33.003 信息 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Closing Spring root WebApplicationContext
30-Mar-2019 18:11:33.004 严重 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStop Exception sending context destroyed event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
 java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
	at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:172)
	at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1071)
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1045)
	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:993)
	at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:548)
	at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
	at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4715)
	at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5374)
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:187)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1729)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289)
	at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809)
	at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:457)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:406)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289)
	at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809)
	at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466)
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307)
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399)
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)






回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
答案 或者 代码至少填写一项, 如果是自己有问题,请重新提问,否则站长有可能看不到





2018-12-20 为什么感觉很难啊
java迷途小菜鸡
感觉很复杂啊,各种配置各种注解弄的很头大啊,怎么办啊




1 个答案

丽丽哒云儿 答案时间:2019-05-08
多复习吧 感觉没有什么好办法



回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
答案 或者 代码至少填写一项, 如果是自己有问题,请重新提问,否则站长有可能看不到




2018-04-20 注解下的客户端跳转
2018-01-12 谁写了 注解方式的 ProductAction代码 能贴出来看看嘛?
2017-11-15 @Resource无法识别,不能自动import
2017-08-19 @Repository和@Service注解时什么意思?




提问之前请登陆
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
关于 JAVA 框架-SSH-整合-注解方式 的提问

尽量提供截图代码异常信息,有助于分析和解决问题。 也可进本站QQ群交流: 1001964108
提问尽量提供完整的代码,环境描述,越是有利于问题的重现,您的问题越能更快得到解答。
对教程中代码有疑问,请提供是哪个步骤,哪一行有疑问,这样便于快速定位问题,提高问题得到解答的速度
在已经存在的几千个提问里,有相当大的比例,是因为使用了和站长不同版本的开发环境导致的,比如 jdk, eclpise, idea, mysql,tomcat 等等软件的版本不一致。
请使用和站长一样的版本,可以节约自己大量的学习时间。 站长把教学中用的软件版本整理了,都统一放在了这里, 方便大家下载: http://how2j.cn/k/helloworld/helloworld-version/1718.html

上传截图