Spring+SpringMVC+Hibernate项目环境搭建的步骤(图文)

  • 工具篇:Intellij Idea+maven+Spring+SpringMVC
  • Spring+SpringMVC环境搭建

一、SpringMVC环境搭建

1、创建新项目

(1)、第一步是创建一个由Maven原型的项目,根据图片上的步骤一次选择Maven—–>create from archetype—->maven-archtype-webapp

(2)、第二步是填写GroupId 和ArtifactId

(3)、在位置1处选择我们maven安装的目录,在位置2处选择settings.xml的路径(我只是设置了一次之后就是默认的了)

(4)、设置项目名和项目的位置

到这里项目就创建成功了

2、添加Maven中项目所需要的Jar包

在pom.xml中添加项目SpringMVC所依赖的Jar包

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>

 <groupId>com.zbt</groupId>
 <artifactId>enviroment</artifactId>
 <version>1.0-SNAPSHOT</version>
 <packaging>war</packaging>

 <name>enviroment Maven Webapp</name>
 <!-- FIXME change it to the project's website -->
 <url>http://www.example.com</url>

 <properties>
 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 <maven.compiler.source>1.7</maven.compiler.source>
 <maven.compiler.target>1.7</maven.compiler.target>
 </properties>

 <dependencies>
 <!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-aop</artifactId>
  <version>5.0.6.RELEASE</version>
 </dependency>

 <!-- https://mvnrepository.com/artifact/org.springframework/spring-aspects -->
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-aspects</artifactId>
  <version>5.0.6.RELEASE</version>
 </dependency>
 <!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-beans</artifactId>
  <version>5.0.6.RELEASE</version>
 </dependency>
 <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>5.0.6.RELEASE</version>
 </dependency>
 <!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-core</artifactId>
  <version>5.0.6.RELEASE</version>
 </dependency>
 <!-- https://mvnrepository.com/artifact/org.springframework/spring-expression -->
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-expression</artifactId>
  <version>5.0.6.RELEASE</version>
 </dependency>
 <!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-jdbc</artifactId>
  <version>5.0.6.RELEASE</version>
 </dependency>
 <!-- https://mvnrepository.com/artifact/org.springframework/spring-orm -->
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-orm</artifactId>
  <version>5.0.6.RELEASE</version>
 </dependency>
 <!-- https://mvnrepository.com/artifact/org.springframework/spring-tx -->
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-tx</artifactId>
  <version>5.0.6.RELEASE</version>
 </dependency>
 <!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-web</artifactId>
  <version>5.0.6.RELEASE</version>
 </dependency>
 <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-webmvc</artifactId>
  <version>5.0.6.RELEASE</version>
 </dependency>
 <!--servlet相关的Jar包-->
 <dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  <version>3.1.0</version>
  <scope>provided</scope>
 </dependency>

 <dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>jstl</artifactId>
  <version>1.2</version>
 </dependency>

 <dependency>
  <groupId>taglibs</groupId>
  <artifactId>standard</artifactId>
  <version>1.1.2</version>
 </dependency>
 </dependencies>

 <build>
 <finalName>enviroment</finalName>
 </build>
</project>

3、配置web.xml文件

<!DOCTYPE web-app PUBLIC
  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app version="2.4"
   xmlns="http://java.sun.com/xml/ns/j2ee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
  http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 <!--设置我们的url都会交给DispatcherServlet-->
 <welcome-file-list>
 <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
 <servlet>
 <servlet-name>springMVC</servlet-name>
 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
 <init-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:/spring-mvc.xml</param-value>
 </init-param>
 <!--Tomcat 启动时就会初始化DispatcherServlet-->
 <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
 <servlet-name>springMVC</servlet-name>
 <url-pattern>*.do</url-pattern>
 </servlet-mapping>
</web-app>

5、配置spring-mvc.xml文件

在resources文件夹下新建一个spring-mvc.xml。spring-mvc.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: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-2.0.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-2.5.xsd
       http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
 <!--启用spring的一些annotation-->
 <context:annotation-config/>

 <!--自动扫描com.zbt.controller-->
 <context:component-scan base-package="zbt.com.controller"/>

 <!--配置注解驱动可以将request参数绑定到controller参数上-->
 <mvc:annotation-driven/>

 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
  <property name="prefix" value="/WEB-INF/jsp/"></property>
  <property name="suffix" value=".jsp"></property>
 </bean>

</beans>

6、编写Controller类

package controller;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/student")
public class StudentController {
 private static final Log logger = LogFactory.getLog(StudentController.class);
 @RequestMapping("/hello")
 public String sayHi(){
  logger.info("sayHi are called!");
  return "hello";
 }
}

在WEB-INF/jsp文件夹下创建测试的hello.jsp

<html>
<body>
 <h2>Hello World!</h2>
</body>
</html>

启动服务器,在浏览器中输入

http://localhost:8088/student/hello.do

显示结果为

注意事项

(1)、url-pattern最好配置成下面的形式

<servlet-mapping>
 <servlet-name>springMVC</servlet-name>
 <url-pattern>*.do</url-pattern>
</servlet-mapping>

而不是下面这种形式

<servlet-mapping>
 <servlet-name>springMVC</servlet-name>
 <url-pattern>/*</url-pattern>
</servlet-mapping>

配置成第二种模式会出现下面的情况

27-Jun-2018 15:04:02.761 警告 [http-nio-8088-exec-8] org.springframework.web.servlet.DispatcherServlet.noHandlerFound No mapping found for HTTP request with URI [/WEB-INF/jsp/hello.jsp] in DispatcherServlet with name 'springMVC'

网页会出现如下情况

(2)、我们的spring-mvc.xml是放在resources文件夹下面的,以后就按照这种方式编写(注意这是在Intellij idea中,在Eclipse中我不知道会不是是一样的)

<init-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:/spring-mvc.xml</param-value>
 </init-param>

二、Spring+SpringMVC环境搭建

编写StudentService

package com.zbt.service;

import org.springframework.stereotype.Service;

/**
 * Created by luckyboy on 2018/7/2.
 */
@Service
public class StudentService {
 public String test(){
  return "hello";
 }
}

创建applicationConfig配置文件

<?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: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/aop
  http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context-4.3.xsd
  http://www.springframework.org/schema/tx
  http://www.springframework.org/schema/tx/spring-tx-4.3.xsd ">
 <context:component-scan base-package="com.zbt">
  <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
 </context:component-scan>
</beans>

注意Spring这里的包扫描方式为,Spring扫描包的时候会排出@Controller注解,也就是不会扫描com.zbt.controller包

<context:component-scan base-package="com.zbt">
 <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>

修改spring-mvc.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: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-2.0.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-2.5.xsd
       http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
 <!--启用spring的一些annotation-->
 <context:annotation-config/>

 <!--自动扫描com.zbt 而不是com.zbt.controller包-->
 <context:component-scan base-package="com.zbt"/>

 <!--配置注解驱动可以将request参数绑定到controller参数上-->
 <mvc:annotation-driven/>

 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
  <property name="prefix" value="/WEB-INF/jsp/"></property>
  <property name="suffix" value=".jsp"></property>
 </bean>

</beans>

将StudentService注入到StudentController中

package com.zbt.controller;

import com.zbt.service.StudentService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by luckyboy on 2018/6/27.
 */
@Controller
@RequestMapping("/student")

 private static final Log logger = LogFactory.getLog(StudentController.class);

 //使用Autowired将StudentService注入到StudentController中
 @Autowired
 private StudentService stuService;

 @RequestMapping("/hello.do")
 public String sayHi(){
  logger.info("sayHi are called!");
  return "hello";
 }

 @RequestMapping("/spring_hello.do")
 public String springSayHi(){
  logger.info("sayHi are called by springSayHi");
  return stuService.test();
 }

}

在StudentService类上面添加@Service注解

package com.zbt.service;

import org.springframework.stereotype.Service;

/**
 * Created by luckyboy on 2018/7/2.
 */
@Service
public class StudentService {
 public String test(){
  return "hello";
 }
}

测试

启动服务器,在浏览器地址栏输入http://localhost:8088/student/spring_hello.do,响应如下

注意事项

我们在spring-mvc.xml中的配置包扫描时,如果包扫描配置如下

<!--错误配置方式-->
<context:component-scan base-package="com.zbt.controller"/>
<!--正确配置方式
<context:component-scan base-package="com.zbt"/>
-->

出现的错误

org.springframework.web.servlet.FrameworkServlet.initServletBean Context initialization failed
 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'studentController': Unsatisfied dependency expressed through field 'stuService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.zbt.service.StudentService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587)
 at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91)
 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1348)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:578)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501)
 at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
 at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:672)
 at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:638)
 at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:686)
 at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:554)
 at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:499)
 at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:172)
 at javax.servlet.GenericServlet.init(GenericServlet.java:158)
 at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1144)
 at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:983)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4939)
 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5249)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
 at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1736)
 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.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
 at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
 at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
 at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:482)
 at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:431)
 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.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
 at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
 at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
 at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
 at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
 at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
 at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
 at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
 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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
 at sun.rmi.transport.Transport$1.run(Transport.java:200)
 at sun.rmi.transport.Transport$1.run(Transport.java:197)
 at java.security.AccessController.doPrivileged(Native Method)
 at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
 at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
 at java.security.AccessController.doPrivileged(Native Method)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
 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)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.zbt.service.StudentService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1509)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065)
 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584)
 ... 67 more

会出现包无法扫描的情况,因此我们在spring-mvc.xml中应该配置成扫描所有的包

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

(0)

相关推荐

  • 浅谈SpringMVC+Spring3+Hibernate4开发环境搭建

    早期的项目比较简单,多是用JSP .Servlet + JDBC 直接搞定,后来使用 Struts1(Struts2)+Spring+Hibernate, 严格按照分层概念驱动项目开发,这次又使用 Spring MVC取代Struts来进行开发. MVC已经是现代Web开发中的一个很重要的部分,下面介绍一下SpringMVC+Spring3+Hibernate4的开发环境搭建 先大致看一下项目结构: 具体的代码不再演示,主要是走了一个很平常的路线,mvc-servcie-dao-hibernat

  • Spring+SpringMVC+Hibernate项目环境搭建的步骤(图文)

    工具篇:Intellij Idea+maven+Spring+SpringMVC Spring+SpringMVC环境搭建 一.SpringMVC环境搭建 1.创建新项目 (1).第一步是创建一个由Maven原型的项目,根据图片上的步骤一次选择Maven-–>create from archetype-->maven-archtype-webapp (2).第二步是填写GroupId 和ArtifactId (3).在位置1处选择我们maven安装的目录,在位置2处选择settings.xml

  • hibernate框架环境搭建具体步骤(介绍)

    一. 概述:hibernate框架是作用于dao层的,实现对数据的持久化保存.通过面向对象的方式操作数据库. 二. hibernate框架的搭建 1.导包 lib目录下的required文件夹下的所有jar包. mysql驱动包. 2.创建数据库于表. 3.创建实体类. 4.创建实体映射文件(以crm练习Customer类为例) 实体类名.hbm.xml 引入约束文件 <?xml version="1.0" encoding="UTF-8"?> <

  • 从零开始的TensorFlow+VScode开发环境搭建的步骤(图文)

    VScode不愧是用户数量上升最快的编辑器,界面华丽(当然,需要配合各种主题插件),十分容易上手且功能强大.之前用它写C++体验十分nice,现在需要学习tensorflow,而工欲善其事必先利其器,搭建一个舒服的开发环境是非常重要的第一步. 目标:在linux下从无到有,安装anaconde3, tensorflow, 配置vs code,直到可以运行一个tensorflow版hello world(实为mnist手写数据分类).尽管有其他的安装tensorflow的方式,但使用anacond

  • Python+Selenium实现自动化的环境搭建的步骤(图文)

    1.在浏览器下载与浏览器相对于的驱动并放到python的安装根目录下 驱动的两个下载地址: http://chromedriver.storage.googleapis.com/index.html http://npm.taobao.org/mirrors/chromedriver/ a.先找到浏览器的版本 b.找到与浏览器对应的驱动 c.把下载好的驱动放到python安装目录的根目录下 2.点击设置 3.添加selenium 4.搜索selenium并添加 5.输入以下代码并运行,如果能打开

  • Hibernate之环境搭建及demo分享

    ORM概念 ORM即Object/Relation Mapping, 对象/关系数据库映射.ORM是一种规范,完成面向对象编程语言到关系数据库之间的映射.J2EE中的JPA就是一种ORM规范. ORM框架有很多,例如JPA, Hibernate,iBATIS等. Hibernate简介 Hibernate是JBoss旗下,同时也是RetHat组织的产品(JBoss加入了RetHat),是目前非常流行的ORM框架. Hibernate中的重要概念为PO(Persistent Object), Hi

  • Maven 搭建SpringMVC+Hibernate项目详解

    前言 今天复习一下SpringMVC+Hibernate的搭建,本来想着将Spring-Security权限控制框架也映入其中的,但是发现内容太多了,Spring-Security的就留在下一篇吧,这篇主要搭建SpringMVC4.1.4和Hibernate4.3.8,之前也打了好多SpringMVC的,这部分已经非常的熟悉了,毕竟业开发过一年多SpringMVC的,这次持久层采用Hibernate,数据源采用c3p0,数据库暂采用MySQL,主要是想复习一下Hibernate.搭建Spring

  • Java框架篇:Spring+SpringMVC+hibernate整合开发

    前言: 最近没什么事做,搭个框架写成博客记录下来,拉通一下之前所学知识. 话不多说,我们直接步入正题. 准备工作: 1/安装并配置java运行环境 2/数据库的安装配置(Mysql) 3/安装并配置服务器(Tomcat) 4/Maven 5/ IntelliJIDEA的安装配置(本人使用的主要软件是IntelliJIDEA,没用eclipse什么的) 6/ 使用IntelliJIDEA创建一个web app项目. 貌似就这些了吧 导包 不同于以往的导包,由于我们创建的是maven的webapp项

  • 基于spring+springmvc+hibernate 整合深入剖析

    目录 1.新建一个maven web项目 2.pom文件,导入jar包 3.配置文件 4.spring-mvc和spring整合 5.spring和hibernate整合 6.总结 三大框架反反复复搭了很多次,虽然每次都能搭起来,但是效率不高.最近重新搭了一次,理顺了思路,整理了需要注意的地方,分享出来. 工具:Eclipse(jdk 1.7) spring和hibernate版本均为4.0以上 推荐使用maven构建项目,相比自己手动导入jar包要方便很多. 1.新建一个maven web项目

  • Vue2.0 从零开始_环境搭建操作步骤

    简要:继项目空闲后,开始着手vue的学习;为此向大家分享其中的艰辛和搭建办法,希望能够跟各位VUE大神学习探索,如果有不对或者好的建议告知下:*~*! 一.什么是VUE? 是一种node.js框架,特点如下: 1.数据绑定 (特性:双向绑定:一旦发生变化,Dom节点实时更新:PS:尽量抛弃JQ,次特点已经可以解决很多特效等问题) 2.组件化(比如:乐高积木一样通过互相引用而组装起来) 二.开发环境 三.环境搭建 1. 包管理器安装 (1) Homebrew安装 (mac 环境,win无法安装)

  • Android Studio安装配置、环境搭建详细步骤及基本使用的详细教程

    前言 Android Studio的安装配置及使用篇终于来啦~ 废话不多说,以下针对JDK正确安装(及其环境变量配置完毕,即Java开发环境下).Android Studio的安装,配置,以及创建工程.主题字体更换.窗口工具.布局.快捷方式等的基本使用逐一说明. 安装java 下载Java安装包(jdk,网上有很多下载地址,最好去官网下:https://www.java.com/zh_CN/),安装完后记得配置环境变量: 在"系统变量"新建一个变量名为JAVA_HOME的变量,变量值为

随机推荐