修改mybatis配置

This commit is contained in:
lsy
2017-09-09 15:45:03 +08:00
parent 0609724bc1
commit e3e6823c7a
9 changed files with 55 additions and 29 deletions
+3 -1
View File
@@ -1,4 +1,4 @@
**可以使用传统方式运行,还可以使用docker
**可以使用传统方式运行,可以使用docker
容器的方式运行。程序的启动顺序是配置中心,
注册中心,其他服务。无论是使何种方式运行,
保证除配置中心外,其他所有服务都能从配置中
@@ -7,6 +7,8 @@
中心外所有服务的注册空间的配置空间都指定正
确,本项目中本地运行时则是都指定到本机的
ip地址**
###本项目开发的相关约定
###配置中心 端口号 9999 监控 19999
www.config.server.com
###注册中心 端口号 10002 监控 20002
-10
View File
@@ -183,16 +183,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--生成mybatis dao 层 sql mapper的插件-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
<!--将lib目录下的文件编译时打包-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -0,0 +1,12 @@
package com.micro.fast.common.config;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties
@AutoConfigureBefore(com.micro.fast.common.config.DataSourceConfig.class)
public class DruidConfig {
}
@@ -19,6 +19,15 @@ import javax.sql.DataSource;
import java.io.IOException;
import java.util.Properties;
/**
* mybatis的相关配置
* create by lishouyu 2017/09/09
* email 18332763730@163.com
*
* last edit lishouyu 2017/09/09
* email 18332763730@163.com
*
*/
@Configuration
@EnableTransactionManagement
public class SqlSessionFactoryConfig implements TransactionManagementConfigurer{
@@ -32,7 +41,7 @@ public class SqlSessionFactoryConfig implements TransactionManagementConfigurer{
//注入数据源
sqlSessionFactoryBean.setDataSource(dataSource);
//设置实体类所在的位置
sqlSessionFactoryBean.setTypeAliasesPackage("com.kklt.pojo");
sqlSessionFactoryBean.setTypeAliasesPackage("com.micro.fast.upms.pojo");
//设置mapper映射文件的位置
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
try {
+10
View File
@@ -94,6 +94,16 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--生成mybatis dao 层 sql mapper的插件-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
</plugins>
</build>
@@ -1,11 +1,13 @@
package com.micro.fast.upms;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
@SpringCloudApplication
@EnableFeignClients
@MapperScan(basePackages = {"com.micro.fast.upms.dao"})
public class UpmsApplication {
public static void main(String[] args) {
@@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!--导入属性配置-->
<properties resource="datasource.properties"></properties>
<properties resource="mybatisGenerator.properties"></properties>
<!--指定特定数据库的jdbc驱动jar包的位置-->
<classPathEntry location="${db.driverLocation}"/>
@@ -39,7 +39,7 @@
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径
-->
<javaModelGenerator targetPackage="com.kklt.pojo" targetProject="./src/main/java">
<javaModelGenerator targetPackage="com.micro.fast.upms.pojo" targetProject="./src/main/java">
<!-- 是否允许子包,即targetPackage.schemaName.tableName -->
<property name="enableSubPackages" value="false"/>
<!-- 是否对model添加 构造函数 -->
@@ -64,24 +64,20 @@
<!-- targetPackage:mapper接口dao生成的位置 -->
<!--<javaClientGenerator type="XMLMAPPER" targetPackage="com.mmall.dao" targetProject=".\src\main\java">-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.kklt.dao" targetProject="./src/main/java" >
<javaClientGenerator type="XMLMAPPER" targetPackage="com.micro.fast.upms.dao" targetProject="./src/main/java" >
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<table tableName="shipping" domainObjectName="Shipping" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="cart" domainObjectName="Cart" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="cart_item" domainObjectName="CartItem" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="category" domainObjectName="Category" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="order" domainObjectName="Order" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="order_item" domainObjectName="OrderItem" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="pay_info" domainObjectName="PayInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="product" domainObjectName="Product" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
<!--设置类型映射的时候使用指定的数据类型-->
<columnOverride column="detail" jdbcType="VARCHAR" />
<columnOverride column="sub_images" jdbcType="VARCHAR" />
</table>
<table tableName="user" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_log" domainObjectName="UpmsLog" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_organization" domainObjectName="UpmsOrganization" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_permission" domainObjectName="UpmsPermission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_role" domainObjectName="UpmsRole" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_role_permission" domainObjectName="UpmsRolePermission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="system" domainObjectName="System" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_user" domainObjectName="UpmsUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_user_organization" domainObjectName="UpmsUserOrganization" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_user_permission" domainObjectName="UpmsUserPermission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="upms_user_role" domainObjectName="UpmsUserRole" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
@@ -0,0 +1,5 @@
db.driverLocation=/root/mysql-connector-java-5.1.40-bin.jar
db.driverClassName=com.mysql.jdbc.Driver
db.url=jdbc:mysql://127.0.0.1:3306/micro?useUncoide=true&chracterEncoding=utf-8&useSSL=true
db.username=root
db.password=studyj2e