https://github.com/QiSimon/Projects.git
https://github.com/QiSimon/Projects.git
Window->Preferences->Java->Installed JREs
在右边的"Installed JREs:"窗口中选中所使用的JRE,
点击其右边的"Edit",在弹出的"Edit JRE"窗口中,
有一个"JRE system libraries:"列表,
在其中找到 "...jdk1.6.0_13\jre\lib\rt.jar" 并选中,
点击右边的"Source Attachment...",
在弹出的"Source Attachment Configuration"界面中,
点击文本框右边的"External File",
选择你下载的源文件zip包,一路OK即可
https://repo.spring.io/libs-release-local/org/springframework/spring/5.0.2.RELEASE/spring-framework-5.0.2.RELEASE-dist.zip
配置文件上哪下载?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
</struts>
struts:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="bl" extends="struts-default" namespace="/">
<action name="Yisheng_*" class="yishengAction" method="{1}">
</action>
</package>
</struts>
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:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- 引入外部的属性文件 --> <context:property-placeholder location="classpath:jdbc.properties" /> <!-- 配置连接池 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${jdbc.driverClass}" /> <property name="jdbcUrl" value="${jdbc.url}" /> <property name="user" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> <!-- hibernate相关属性配置--> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">true</prop> <prop key="hibernate.hbm2ddl_auto">update</prop> </props> </property> <property name="mappingResources"> <list> <value>domin/TYisheng.hbm.xml</value> <value>domin/TKeshi.hbm.xml</value> </list> </property> </bean> <!-- action配置 --> <bean id="yishengAction" class="action.YishengAction" scope="prototype"> <property name="yishengService" ref="yishengService"></property> </bean> <!-- 业务层配置 --> <bean id="yishengService" class="service.YishengService"> <property name="yishengDao" ref="yishengDao"> </property> </bean> <!-- dao层配置 --> <bean id="yishengDao" class="dao.YishengDao"> </bean> </beans>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<listener>
<listener-class> org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>
报错了还是什么?
老师用的是spring-web-3.2.0.RELEASE-source.jar, 说明你没有下载这个JAR包吧
虽然你说的不是很清楚,但是我能猜到,应该是你的配置文件有点问题,导致你服务器没有起来,服务器没起来的话所有对你服务器的请求都会报404的错误,不知道是不是这个问题,如果不是回复我,帮你解答
直接放在src下 在applicationContext.xml中会有调用
https://github.com/Utihbi/ssh
额,记下来完全没必要啊,清楚骨架就行了,剩下的如果是新手就可以去搜索,多写写,慢慢就熟悉了,不是说一定要记住,但是能记住就可以证明尿性足!
是啊,请问如何找到application.xml.
能不能发我一个
可能是spring的版本不同
web.xml中要如下配置Spring:
<!-- Spring框架核心监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml
</param-value>
</context-param>
<!-- 配置Action的类 -->
<bean id="productAction" class="action.ProductAction" scope="prototype">
<!-- 手动注入Service -->
<property name="priductService" ref="productService"></property>
</bean>
<!-- 配置业务层的类 -->
<bean id="productService" class="service.ProductService">
<property name="productDao" ref="productDao"/>
</bean>
<!-- 配置Dao类 -->
<bean id="productDao" class="dao.ProductDao"> </bean>
class要写全类名
你的意思是否要生成sturts.xml文件?
ERROR - Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 31 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 31; columnNumber: 4; cvc-elt.1: 找不到元素 'beans' 的声明。
直接用这个吧:
log4j.rootLogger=DEBUG,Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
log4j.logger.org.apache=INFO
Alt+回车
我有!!!!!!!!!!!
发邮箱我给你发!
spring配置文件中加载的东西比较多,并且你
这么配置过后,只要一开启服务器,先读取web.xml文件,然后读到这里的时候就会去加载spring的配置文件,如果spring配置文件里有加载数据库的,就要先打开数据库服务,不然项目启动就会报错。
log4j.rootLogger = debug, console, E
#level=INFO,all can be output
#console is set to be a ConsoleAppender
log4j.appender.console = org.apache.log4j.ConsoleAppender
log4j.appender.console.layout = org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern = [%p] %d{yyyy-MM-dd HH:mm:ss} - %m%n
#file is set to output to a extra file
log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
log4j.appender.E.layout = org.apache.log4j.PatternLayout
log4j.appender.E.Threshold=error
log4j.appender.E.Encoding=UTF-8
log4j.appender.E.layout.ConversionPattern=[%p] %d{yyyy-MM-dd HH:mm:ss} - %m%n
log4j.appender.E.DatePattern='.'yyyy-MM-dd
log4j.appender.E.File = ${catalina.base}/logs/dd/error.log
Ctrl+Shift+T