项目配置
教学视频
添加baskserver相关的jar
Java Web Project
下载依赖包根据自己的需要配置相关的依赖包,并添加到项目的lib目录下
Maven Web Project
- 如果你是SpringBoot2项目,我们提供了一个模版项目: https://gitee.com/xiaodaodao/baskserver-boot 可以直接下载下来参考
如果你是SpringBoot3项目,我们提供了一个模版项目: https://gitee.com/xiaodaodao/baskserver-boot3 可以直接下载下来参考
配置pom.xml的依赖以Maven项目为例,在pom.xml中添加配置:
<!--BaskReport--> <dependency> <groupId>com.basksoft</groupId> <artifactId>baskreport</artifactId> <version>${baskreport.version}</version> </dependency> <dependency> <groupId>com.basksoft</groupId> <artifactId>baskreport-font</artifactId> <version>${baskreport-font.version}</version> </dependency> <!--BaskAdapt--> <dependency> <groupId>com.basksoft</groupId> <artifactId>baskadapt</artifactId> <version>${baskadapt.version}</version> </dependency> <!--如果不是spring-boot3项目,需要加入如下的依赖--> <dependency> <groupId>jakarta.servlet</groupId> <artifactId>jakarta.servlet-api</artifactId> <version>5.0.0</version> </dependency>
在实际的使用过程当中,如果需要用到某个版本的SNAPSHOT,那么就需要在pom.xml当中添加一个repository信息,告诉Maven该到这里去下载SNAPSHOT版本的包,snapshot的仓库配置如下:
<repository> <id>sonatype</id> <url>https://s01.oss.sonatype.org/content/groups/public/</url> </repository>
如果通过配置repository无法下载到对应的SNAPSHOT包,则可以直接修改maven的setting.xml文件,在其中添加一个mirror配置:
<mirror> <id>sonatype</id> <url>https://s01.oss.sonatype.org/content/groups/public/</url> </mirror>
添加BaskFilter配置
web项目
在web.xml中添加如下的filter
<filter> <filter-name>baskserver</filter-name> <filter-class>com.basksoft.core.BaskFilter</filter-class> </filter> <filter-mapping> <filter-name>baskserver</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
springboot2项目
添加BaskFilter配置
import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import com.basksoft.core.BaskFilter; @Configuration public class BaskServerConfig implements WebMvcConfigurer { @Bean public FilterRegistrationBean<BaskFilter> registerReportFilter() { FilterRegistrationBean<BaskFilter> registration = new FilterRegistrationBean<BaskFilter>(new BaskFilter()); registration.addUrlPatterns("/*"); registration.setName("baskserver"); registration.setOrder(1); return registration; } }
springboot3项目
添加BaskJakartaFilter配置
import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import com.basksoft.core.BaskJakartaFilter; @Configuration public class BaskServerConfig implements WebMvcConfigurer { @Bean public FilterRegistrationBean<BaskFilter> registerReportFilter() { FilterRegistrationBean<BaskJakartaFilter> registration = new FilterRegistrationBean<BaskJakartaFilter>(new BaskJakartaFilter()); registration.addUrlPatterns("/*"); registration.setName("baskserver"); registration.setOrder(1); return registration; } }
完成数据库初始化
我们可以利用向导自动完成数据库的初始化,也可以利用sql脚本完成初始化工作