朋友是作线缆生意的,想要一个进销存管理可是网上的现成的不太试用,功能太多操做繁琐,对于以米为单位的线缆,库存不能简单的加减。须要定制一个功能精简的进销存。html
项目源码地址:https://github.com/Gengry/zlxsC前端
数据库文件在data目录下,最新的导入便可12开头的是17年的文件,01开头的是18年的当时只是用月日标识没有加年。java
以前用过一点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。mysql
spring boot集成druid文档(https://github.com/alibaba/druid/tree/master/druid-spring-boot-starter)。我并无使用spring boot druid starter,而且关闭了spring boot datasource auto configuration。jquery
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
配置datasource。git
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.htmlgithub
对pom.xml加入以下配置spring
<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)。sql
配置 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
没有作权限控制。