作者:gaoxuxinyue23 | 来源:互联网 | 2023-05-19 16:06
github地址:https:github.comrongyaya10…不使用Maven,创建SSH(Spring+SpringMVC+Hibernate)的方法:IntelliJ
github地址:https://github.com/rongyaya10…
不使用Maven,创建SSH(Spring+SpringMVC+Hibernate)的方法:
新建Project
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/9b0d/ae9/2d998ad7838fbf16.jpeg)
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/189d8/978/7dbdf0f38ad53545.jpeg)
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/e88efe5b0a13a7fa.webp)
下载jar,请稍等
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/8170a21e8dddfd22.webp)
目录结构
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1e618/bdf/129913486c37ddf6.jpeg)
配置Project Structure
【File】-【Project Structure】
配置Modules
在src下,新建main – java (java目录变更Sources)
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/60405fda58cd0acd.webp)
配置Problems
如果在Problems中有标的数字,请点击,选择【fix】-【Add…】
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/5b97d3b808d031e2.webp)
配置Artifacts(war模块)
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/67cc2e96eddffff8.png)
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/bff2716168d1ed7b.webp)
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/b386c433a16f5497.webp)
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/d05d9dfd09a56332.webp)
配置Libraries(jar)
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/6789f68dabde0aed.png)
选择目录下的【lib】文件夹
添加:
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/c72d78d7317a9e8e.webp)
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/086aec93f5e1e9b2.webp)
目录结构:
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/4283cd4bbba41b87.png)
配置文件修改
配置web.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
contextConfigLocation
/WEB-INF/applicationContext.xml
org.springframework.web.context.ContextLoaderListener
dispatcher
org.springframework.web.servlet.DispatcherServlet
1
dispatcher
*.form
配置dispatcher-servlet.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cOntext="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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">
下载 jstl.jar 1.2 和 standard.jar 1.1.2
http://repo2.maven.org/maven2…
http://repo2.maven.org/maven2…
导入jar
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/7494af3c1cda418d.webp)
选择Problems,点击【fix】
更改目录结构,增加target文件夹,编译后文件可存入这个文件夹
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/ed19db63ee478b98.png)
更改文件夹后,修改
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/2fdc212433a29829.png)
修改war:
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/70be2ca197098d98.webp)
配置tomcat
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/7494af3c1cda418d.webp)
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/60405fda58cd0acd.webp)
coding
【controller】- 新建IndexController.java
package com.zgr.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class IndexController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index() {
return "index";
}
}
【pages】 – index.jsp
<%--
Created by IntelliJ IDEA.
User: zgr
Date: 2017/7/26
Time: 15:16
To change this template use File | Settings | File Templates.
--%>
<%@ page cOntentType="text/html;charset=UTF-8" language="java" %>
web
运行:
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1eebe/cd5/fb32005f2115b419.webp)
成功!
![《IntelliJ idea 不使用Maven创建Spring+SpringMVC+Hibernate的方法》](https://img.php1.cn/3cd4a/1e618/bdf/129913486c37ddf6.jpeg)