线缆库存管理程序

前言:

    朋友是做线缆生意的,想要一个进销存管理但是网上的现成的不太试用,功能太多操作繁琐,对于以米为单位的线缆,库存不能简单的加减。需要定制一个功能精简的进销存。

    项目源码地址:https://github.com/Gengry/zlxsC

    数据库文件在data目录下,最新的导入即可12开头的是17年的文件,01开头的是18年的当时只是用月日标识没有加年。

技术选型:

    之前用过一点spring boot但是项目不是自己搭建的,最近在看spring boot就用他吧。前端试用的zheng admin ui(https://github.com/shuzheng/zhengAdmin)是基于bootstarp的,函数库Jquery,数据表格 bootstrap table,select2,jquery-confirm,zheng common的baseservice,mybatis,mybatis generator, druid,mysql,maven。

    spring boot集成druid文档(https://github.com/alibaba/druid/tree/master/druid-spring-boot-starter)。我并没有使用spring boot druid starter,并且关闭了spring boot datasource auto configuration。

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})

配置datasource。

package com.zhonglianxs.erp.cpw.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInterceptor;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Properties;

//生命为java配置类
@Configuration
//开启spring事物支持
@EnableTransactionManagement
//配置mybatis mapper扫描
@MapperScan(value = "com.zhonglianxs.erp.cpw.mapper")
public class DataBaseConfiguration implements EnvironmentAware{

    private Environment environment;
    private RelaxedPropertyResolver propertyResolver;
    @Override
    public void setEnvironment(Environment environment) {
        this.environment = environment;
        this.propertyResolver = new RelaxedPropertyResolver(environment,"spring.datasource.");
    }

    //配置druidDataSource
    @Bean(name = "druidDataSource" ,initMethod = "init",destroyMethod = "close")
    public DruidDataSource dataSource(){
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setDriverClassName(propertyResolver.getProperty("driverClassName"));
        druidDataSource.setUrl(propertyResolver.getProperty("url"));
        druidDataSource.setUsername(propertyResolver.getProperty("username"));
        druidDataSource.setPassword(propertyResolver.getProperty("password"));
        druidDataSource.setMaxActive(20);
        druidDataSource.setInitialSize(1);
        druidDataSource.setMaxWait(60000);
        druidDataSource.setTimeBetweenEvictionRunsMillis(60000);
        druidDataSource.setMinEvictableIdleTimeMillis(300000);
        druidDataSource.setTestWhileIdle(true);
        druidDataSource.setTestOnBorrow(false);
        druidDataSource.setTestOnReturn(false);
        druidDataSource.setPoolPreparedStatements(true);
        druidDataSource.setMaxOpenPreparedStatements(20);
        druidDataSource.setValidationQuery("SELECT 'x'");
        return druidDataSource;
    }

    //配置mybatis sqlsessionFactory
    @Bean public SqlSessionFactory sqlSessionFactory(@Qualifier("druidDataSource") DataSource dataSource) throws Exception {
        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
        sqlSessionFactoryBean.setDataSource(dataSource);
        //配置mybatis分页插件
        Properties props = new Properties();
        props.setProperty("offsetAsPageNum", "false");
        props.setProperty("rowBoundsWithCount", "true");
        props.setProperty("pageSizeZero", "false");
        props.setProperty("reasonable", "false");
        props.setProperty("params", "pageNum=pageNum;pageSize=pageSize;count=countSql;reasonable=reasonable;pageSizeZero=pageSizeZero");
        props.setProperty("supportMethodsArguments","false");
        props.setProperty("autoRuntimeDialect","true");

        PageInterceptor pageInterceptor = new PageInterceptor();
        pageInterceptor.setProperties(props);
        sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageInterceptor});
        //配置mybatis xml文件路径
        PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath*:com/zhonglianxs/erp/cpw/mapping/*.xml"));
        return sqlSessionFactoryBean.getObject();
    }
    
    //配置spring 事物管理器
    @Bean public PlatformTransactionManager transactionManager() throws SQLException {
        return new DataSourceTransactionManager(dataSource());
    }

}

发现启动后获取不到mybatis中的定义的方法,查了查都是说mapper名字和xml名字定义不一致什么的,但是检查后发现是一致的,maven package后打开打包文件,发现其中没有resource目录下的xml文件。应该是maven配置问题。参考https://www.cnblogs.com/pixy/p/4798089.html

对pom.xml加入如下配置

<resources>
            <resource>
                <directory>src/main/resources</directory>
				<includes>
					<include>**/*.properties</include>
					<include>**/*.xml</include>
					<include>**/**</include>
				</includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>

配置spring mvc messageConConverter(https://my.oschina.net/u/3714931/blog/1594680)。

配置 jsp,一开始如果不部署在tomcat下解析不了jsp,因为spring boot没有自动集成解析jsp的包。参考http://tengj.top/2017/03/13/springboot5/

pom.xml文件中配置

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.tomcat.embed</groupId>
			<artifactId>tomcat-embed-jasper</artifactId>
			<!--<scope>provided</scope>-->
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jstl</artifactId>
			<version>1.2</version>
		</dependency>

配置jsp开发模式不需要重启直接生效

server.jsp-servlet.init-parameters.development=true

没有做权限控制。

界面效果:

    180215_YZ36_3714931.png

180235_QASm_3714931.png

180253_j12N_3714931.png

 

180307_dAfS_3714931.png

180322_KvUO_3714931.png

180337_yoeU_3714931.png

 

转载于:https://my.oschina.net/u/3714931/blog/1603618

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值