Server2016开发环境配置

Server2016的虚拟机安装激活、评估版升级正式版之后,开始着手配置开发环境。
首先配置下面的内容

  1. java及环境变量
  2. tomcat 使用端口6054
  3. apache 使用端口80 (安装配置php)
  4. mysql 使用端口6062
  5. phpmyadmin
  6. eclipse
  7. eclipse中配置spring、hibernate
  8. maven

下面截图记录上述配置内容:
1.java安装
screenshot
screenshot
screenshot
screenshot
screenshot
java环境变量
位置
screenshot
JAVA_HOME
screenshot
path
screenshot
配置了path以后就可以使用javac命令了如下图:
screenshot
classpath
screenshot

2.安装tomcat
tomcat作为java容器和我们的主应用服务器,将来都访问它,我们使用端口号6054。
一个压缩包,解压缩直接拷贝到C盘根目录
screenshot
添加一个环境变量:CATALINA_HOME
screenshot
然后基于它在path和classpath中配置tomcat的路径
screenshot
配置了path之后,就可以命令行直接startup了
如下图:
screenshot
screenshot
修改tomcat的端口号
screenshot
已经可以使用命令行执行tomcat目录下的startup命令打开tomcat服务了
现在我们注册tomcat 服务,以后可以设置开机启动或者在 “服务”中点点鼠标打开服务。
screenshot
看看server2016上的服务
screenshot
测试了一下已经可以通过点鼠标,打开或者关闭服务了。

3.安装apache
apache是作为phpmyadmin的应用服务器,仅用来维护mysql数据库用。
screenshot
解压缩,复制粘贴
screenshot
先注册服务
screenshot
screenshot
screenshot
screenshot
默认使用80端口,不需要修改
但是要修改几个配置参数:

 打开apache24/conf/httpd.conf
 修改:ServerRoot "C:/Apache24"
 修改:DocumentRoot "C:/Apache24/www/ "

screenshot

修改以后,apache的根目录就是C:/Apache24/www/

screenshot
如上图所示,以后apache服务器上的项目就要这样,放置在这个目录了,也就是说phpmyadmin要放在这个目录下。
本机访问apache服务器 使用路径 http://localhost/ 就可以了
如果其他电脑访问本机,就要使用ip地址访问
首先关闭虚拟机server2016的防火墙,如下图
screenshot
既然是虚拟机,最好还是用 桥接 方式的网卡,然后给虚拟机绑定一个ip地址
screenshot
screenshot
经过上述设置以后,局域网内其他PC就可以通过ip地址来访问该虚拟机服务器上的tomcat和apache服务器了。
phpmyadmin工作的前提是apache服务器需要支持php因此下面先为apache配置php环境。有了php的环境,才能安装phpmyadmin。

前往php官网下载php
screenshot
64位线程安全版
screenshot
同样复制到C:根目录
screenshot
然后配置一个php的环境变量
screenshot
screenshot
screenshot
使用命令行 php -h测试一下,应该是可以用了
但是这个阶段直接访问apache上的phpmyadmin项目还是不行的,原因是还没有为apache添加对php的支持的配置
访问的结果如下:
screenshot
这个阶段说明apache服务器还不能识别php的环境,对于apache来说php就是txt
于是,修改apache的配置文件conf目录下的httpd.conf文件
screenshot
修改之后,重启一下apache服务器才能生效,再次访问phpmyadmin的index.php文件,效果如下:
screenshot
尽管报错,但是说明apache服务器已经识别了php环境,只是有一些配置项有问题,需要调一下。
找到php的配置文件php.ini 修改有关于mbstring的配置如下图
screenshot
重新启动apache服务器,然后再次运行phpmyadmin
screenshot
已经可以看到部分画面,说明php.ini的配置有效
下面详述一下php应该有的配置

4.安装配置mysql5.7
首先获取mysql软件
screenshot
最初获取的是mysql community server 5.7.18版 zip文档
但是,方便起见,还是从新下载了msi文件,也就是带有安装配置向导的installer版本:
screenshot
安装的过程会提示端口号的配置、创建用户密码等配置内容。
参考了如下链接提供的攻略:http://www.jb51.net/article/39188.htm
mysql端口号6062
root用户 密码为p密码
charlie用户 密码为w密码
bob用户 密码为简单密码
安装完成以后,查看server2016的服务器管理器
screenshot
发现安装向导为我们添加了mysql的服务
现在使用命令行进入mysql试试密码是否好用
screenshot
screenshot
screenshot
数据库应该是可以用了。

下面返回步骤3,继续配置phpmyadmin对mysql的控制。
phpmyadmin有一个配置文件,名字叫做:config.inc.php
修改这个文件的配置内容:
screenshot
配置以后,发现,已经可以使用mysql刚刚配置的用户名密码进行登陆了,如下图:
screenshot
到此为止,已经可以通过phpmyadmin对mysql数据库的内容进行维护了。
部署了mysql数据库,并可以使用phpmyadmin对mysql进行维护;
部署了apache作为php服务器
部署了tomcat作为java容器和java EE服务器

补充:
1.关闭json验证
image
因为假如不关闭eclipse本身的json校验规则比较严格,如下图所示都是非正规的注释方式,都会报错:
screenshot

2.设置eclipse的编码
配置workspace的编码
screenshot
配置文件类型的编码
screenshot
配置某一个的项目的编码
screenshot
配置某一个具体文件的编码
screenshot
screenshot

3.Spring+Hibernate对于文件夹的扫描
Spring本身的配置文件中只配置扫描dao以及以上层次的文件夹
Hibernate扫描PO层的文件,配置的内容体现在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:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc" 
    xmlns:cache="http://www.springframework.org/schema/cache"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:cxf="http://cxf.apache.org/core"
    xmlns:jaxws="http://cxf.apache.org/jaxws"
    
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        classpath:/org/springframework/beans/factory/xml/spring-beans.xsd     
        http://www.springframework.org/schema/context
        classpath:/org/springframework/context/config/spring-context.xsd
        http://www.springframework.org/schema/aop
        classpath:/org/springframework/aop/config/spring-aop.xsd
        http://www.springframework.org/schema/tx
        classpath:/org/springframework/transaction/config/spring-tx.xsd
        http://www.springframework.org/schema/jdbc
        classpath:/org/springframework/jdbc/config/spring-jdbc.xsd
        http://www.springframework.org/schema/mvc  
        classpath:/org/springframework/web/servlet/config/spring-mvc.xsd
        http://cxf.apache.org/core 
        classpath:/schemas/core.xsd
        http://cxf.apache.org/jaxws 
        classpath:/schemas/jaxws.xsd">  
      
    <context:component-scan base-package="com.threadtest.dao"/>     <!-- 被扫描的DAO文件夹 -->
    <context:component-scan base-package="com.threadtest.service"/>  <!-- 被扫描的Service文件夹 -->   
    <!--com.mysql.cj.jdbc.Driver-->
    <!--配置文件-->    
    <bean id="propertyConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
     <property name="locations">
         <list>
            <value>classpath:/HibernateApplicationContext.properties</value>
         </list>
     </property>
    </bean>
    
    <!-- 配置mysql数据源, 阿里巴巴的druid-->
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
        destroy-method="close" 
        p:driverClassName="${jdbc.driver}"
        p:url="${jdbc.url}"
        p:username="${jdbc.username}"
        p:password="${jdbc.password}" 
        p:initialSize="${ds.initialSize}"
        p:minIdle="${ds.minIdle}"
        p:maxActive="${ds.maxActive}"
        p:maxWait="${ds.maxWait}"
        p:timeBetweenEvictionRunsMillis="${ds.timeBetweenEvictionRunsMillis}"
        p:minEvictableIdleTimeMillis="${ds.minEvictableIdleTimeMillis}"
        p:removeAbandoned="${ds.removeAbandoned}"
        p:removeAbandonedTimeout="${ds.removeAbandonedTimeout}"
        p:defaultAutoCommit="true">
    </bean>    
    
    <!-- spring为集成hibernate提供的LocalSessionFactoryBean -->    
    <!-- 指定数据源 -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate5.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>
          </props>
       </property>
       <property name="packagesToScan" value="com.threadtest.entity"/><!-- 被扫描的PO文件夹 -->
    </bean>
    
    <!-- 配置Hibernate的事务管理器  : 注入SessionFactory 会话工厂 -->
     <bean id="transactionmanager" class="org.springframework.orm.hibernate5.HibernateTransactionManager"> 
         <property name="sessionFactory" ref="sessionFactory"/>
    </bean> 
    
    <!-- 事务管理 通知 -->
    <tx:advice id="txAdvice" transaction-manager="transactionmanager">
        <tx:attributes>
            <!-- 定义以下开头的方法名都是只读的模式 -->
            <tx:method name="select*" read-only="true" />
            <tx:method name="count*" read-only="true" />
            <tx:method name="get*" read-only="true" />
            <tx:method name="query*" read-only="true" />
            <tx:method name="find*" read-only="true" />
            <tx:method name="load*" read-only="true" />
            <!-- 其他所有方法都使用事务 -->
            <tx:method name="*" propagation="REQUIRED" read-only="false"
                rollback-for="Exception" />
        </tx:attributes>
    </tx:advice>
    
    <!--  -->
    <tx:annotation-driven transaction-manager="transactionmanager"/>
    
    <!-- 配置JdbcTemplate -->
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
         <property name="dataSource" ref="dataSource"/>
    </bean>    
       
</beans> 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值