spring boot 直接在Eclipse上跑没有问题,打成jar包之后就无法访问jsp页面了

C.Hang 2017-11-30 11:17:36
如题,spring boot在Eclipse上运行没有问题,也可以通过Controller直接访问jsp页面,但是把项目打成jar包运行之后,可以通过浏览器地址栏执行Controller里面的方法,却不能通过Controller访问jsp页面(访问页面的controller和执行方法的controller是分开的)

访问页面的Controller
package com.qsgw.mission.controller;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@EnableAutoConfiguration
@RequestMapping("/mission")
public class PageController {

@RequestMapping(value = "/index")
public String pageIndex() {
return "index";
}

@RequestMapping("/show")
public String pageShow() {
return "show";
}

@RequestMapping("/manager")
public String pageManager() {
return "manager";
}

@RequestMapping("/add_new_mission_page")
public String pageAddNewMission() {
return "add_new_mission";
}
}


执行方法的controller
package com.qsgw.mission.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.qsgw.mission.entity.Mission;
import com.qsgw.mission.service.MissionService;
import com.qsgw.mission.util.JsonResult;

@RestController
@RequestMapping("/mission")
public class MissionController {

@Resource
private MissionService missionService;

@RequestMapping("allMissionList.do")
public JsonResult allMissionList() {
List<Mission> list = missionService.allMissionList();
return new JsonResult(list);
}
}

百度上的方法基本上都试过了,都没有效果,求答案,求解脱
...全文
4258 29 打赏 收藏 转发到动态 举报
写回复
用AI写文章
29 条回复
切换为时间正序
请发表友善的回复…
发表回复
NiE_ZhangMaoYuan 2018-07-05
  • 打赏
  • 举报
回复
其实 只要将包打为 war格式 就可以了
达兔哥 2018-02-10
  • 打赏
  • 举报
回复
感谢,我看到这个解决了我的问题!
C.Hang 2017-12-05
  • 打赏
  • 举报
回复
引用 24 楼 hanpoyangtitan 的回复:
兄弟,我看了一篇文章,按照里面的把spring-boot-maven-plugin的版本号改成1.4.2,没效果,烦起来之后把整个pom复制过来了,已经可以用了 文章地址http://blog.csdn.net/sdmxdzb/article/details/77977727 这里要谢谢你这么不厌其烦的指导我,谢谢
C.Hang 2017-12-05
  • 打赏
  • 举报
回复
引用 24 楼 hanpoyangtitan 的回复:
我把你的pom跟我的对比,不一样的全改成你那个了,结果是一样的
什么都不能 2017-12-05
  • 打赏
  • 举报
回复
引用 26 楼 chichuhanga 的回复:
[quote=引用 24 楼 hanpoyangtitan 的回复:]
兄弟,我看了一篇文章,按照里面的把spring-boot-maven-plugin的版本号改成1.4.2,没效果,烦起来之后把整个pom复制过来了,已经可以用了 文章地址http://blog.csdn.net/sdmxdzb/article/details/77977727 这里要谢谢你这么不厌其烦的指导我,谢谢[/quote] 客气了,互相切磋,互相学习。
什么都不能 2017-12-05
  • 打赏
  • 举报
回复
引用 23 楼 chichuhanga 的回复:
[quote=引用 22 楼 hanpoyangtitan 的回复:] 不好意思,周末有事不在家 我也不知道为什么我的这个Eclipse上面可以识别jsp,但是打成jar包就不行了
我用你的pom.xml在eclipse上也可以,打包以后访问提示下载。
C.Hang 2017-12-04
  • 打赏
  • 举报
回复
[quote=引用 22 楼 hanpoyangtitan 的回复:] 不好意思,周末有事不在家 我也不知道为什么我的这个Eclipse上面可以识别jsp,但是打成jar包就不行了
xiongdejun 2017-12-01
  • 打赏
  • 举报
回复
你试着调整一下。你把你的jsp相对于你的corr
引用 11 楼 chichuhanga 的回复:
[quote=引用 8 楼 xiongdejun 的回复:] [quote=引用 6 楼 chichuhanga 的回复:] [quote=引用 5 楼 xiongdejun 的回复:] 报的是什么错?404?还是什么
报错信息是这样的[/quote] 404肯定是你路径的问题了。原因的话我大致分析下吧。首先你在Eclipse下是没问题的。然后打包成jar包不行。 在Eclipse中url路径取得是相对路径。比如你得jsp是在Jsp文件夹里的话。取得时候就是jsp/..jsp。 那么你换成jar包。二你得jar包相对之前的位置就变了,所以这时候就要查看下你打包成jar包之后你得jsp文件相对于你得工程的什么位子。 做一下调整即可[/quote] 在Eclipse中跑的时候路径是这样的 spring.mvc.view.prefix=/WEB-INF/jsp/ spring.mvc.view.suffix=.jsp 打成jar包之后路径是这样的[/quote] 你调下把,把你的jsp相对于你的Controller类的路径填在(spring.mvc.view.prefix=/WEB-INF/jsp/)上就可以
C.Hang 2017-12-01
  • 打赏
  • 举报
回复
引用 8 楼 xiongdejun 的回复:
[quote=引用 6 楼 chichuhanga 的回复:]
[quote=引用 5 楼 xiongdejun 的回复:]
报的是什么错?404?还是什么

报错信息是这样的[/quote]

404肯定是你路径的问题了。原因的话我大致分析下吧。首先你在Eclipse下是没问题的。然后打包成jar包不行。
在Eclipse中url路径取得是相对路径。比如你得jsp是在Jsp文件夹里的话。取得时候就是jsp/..jsp。
那么你换成jar包。二你得jar包相对之前的位置就变了,所以这时候就要查看下你打包成jar包之后你得jsp文件相对于你得工程的什么位子。
做一下调整即可[/quote]

在Eclipse中跑的时候路径是这样的
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

打成jar包之后路径是这样的
什么都不能 2017-12-01
  • 打赏
  • 举报
回复
引用 21 楼 chichuhanga 的回复:
[quote=引用 20 楼 hanpoyangtitan 的回复:] 我看了下你的springboot springmvc配置都没有问题, 我看你的controller里的方法只是显示了个视图,没啥逻辑,把启动的日志发出来看看
是这个吗?[/quote] 是,也没有问题啊,上面的几个资源都初始化了。
引用 21 楼 chichuhanga 的回复:
[quote=引用 20 楼 hanpoyangtitan 的回复:] 我看了下你的springboot springmvc配置都没有问题, 我看你的controller里的方法只是显示了个视图,没啥逻辑,把启动的日志发出来看看
是这个吗?[/quote] 我刚用你的pom.xml 试了下,很奇怪,不识别jsp的。我这里是当做资源下载,不显示内容,不清楚是否和这个有关系,建议先暂时保留springboot,先把mybatis的依赖先去掉,试试。附上我这边的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.tom</groupId>
  <artifactId>springboot</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>springboot</name>
  <url>http://maven.apache.org</url>
  <parent>  
        <groupId>org.springframework.boot</groupId>  
        <artifactId>spring-boot-starter-parent</artifactId>  
        <version>1.4.0.RELEASE</version>  
        <relativePath></relativePath>  
  </parent>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
    	<groupId>org.springframework.boot</groupId>
    	<artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <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>
    </dependency>
    <dependency>
    	<groupId>org.springframework.boot</groupId>
    	<artifactId>spring-boot-starter-test</artifactId>
    	<scope>test</scope>
    </dependency>
    <dependency>
    	<groupId>dom4j</groupId>
    	<artifactId>dom4j</artifactId>
    	<version>1.6.1</version>
    </dependency>
  </dependencies>
  <build>  
        <plugins>  
            <plugin>  
                <groupId>org.springframework.boot</groupId>  
                <artifactId>spring-boot-maven-plugin</artifactId>  
            </plugin>  
        </plugins>  
        <resources>  
            <!-- 打包时将jsp文件拷贝到META-INF目录下-->  
            <resource>  
                <!-- 指定resources插件处理哪个目录下的资源文件 -->  
                <directory>src/main/webapp</directory>  
                <!--注意此次必须要放在此目录下才能被访问到-->  
                <targetPath>META-INF/resources</targetPath>  
                <includes>  
                    <include>**/**</include>  
                </includes>  
            </resource>  
            <resource>  
                <directory>src/main/resources</directory>  
                <includes>  
                    <include>**/**</include>  
                </includes>  
                <filtering>false</filtering>  
            </resource>  
        </resources>  
    </build>
</project>
C.Hang 2017-12-01
  • 打赏
  • 举报
回复
引用 20 楼 hanpoyangtitan 的回复:
我看了下你的springboot springmvc配置都没有问题, 我看你的controller里的方法只是显示了个视图,没啥逻辑,把启动的日志发出来看看






是这个吗?
什么都不能 2017-12-01
  • 打赏
  • 举报
回复
引用 19 楼 chichuhanga 的回复:
[quote=引用 18 楼 hanpoyangtitan 的回复:] 还有你启动的时候有没有异常
都不能访问,但凡有一个可以访问的,我就可以顺藤摸瓜把其他的解决了 不管是Eclipse启动还是命令行 java -jar 启动,都没有报错,唯一的区别就是eclipse启动可以访问页面,命令行启动不能[/quote] 我看了下你的springboot springmvc配置都没有问题, 我看你的controller里的方法只是显示了个视图,没啥逻辑,把启动的日志发出来看看
C.Hang 2017-12-01
  • 打赏
  • 举报
回复
引用 18 楼 hanpoyangtitan 的回复:
还有你启动的时候有没有异常
都不能访问,但凡有一个可以访问的,我就可以顺藤摸瓜把其他的解决了 不管是Eclipse启动还是命令行 java -jar 启动,都没有报错,唯一的区别就是eclipse启动可以访问页面,命令行启动不能
什么都不能 2017-12-01
  • 打赏
  • 举报
回复
还有你启动的时候有没有异常
什么都不能 2017-12-01
  • 打赏
  • 举报
回复
引用 16 楼 chichuhanga 的回复:
[quote=引用 15 楼 hanpoyangtitan 的回复:] [quote=引用 14 楼 chichuhanga 的回复:] [quote=引用 13 楼 hanpoyangtitan 的回复:] [quote=引用 3 楼 chichuhanga 的回复:] [quote=引用 1 楼 hanpoyangtitan 的回复:] 你是用main方法启动的还是放到web容器里了?
在Eclipse里面是main方法启动的,然后打成war包是直接cmd用命令启动的 java -jar mission.jar[/quote] 错误截图上显示没有配置/error 我看了你的代码确实没有映射/error的方法 问题是你怎么访问到error的呢?[/quote] error这个似乎是spring boot自带的,当抛出异常的或者找不到页面的时候,会跳转到spring boot自己设置好的error页面[/quote] 我刚试过,找不到文件会提示jsp找不到,你这个是不是方法报错了? [/quote] 会不会是我pom文件配置有问题,刚接触spring boot,基本上都是按照网上的来的,不知道会不会有错,兄弟能帮我看一下吗? pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.aaa</groupId> <artifactId>mission</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring-boot.version>1.5.2.RELEASE</spring-boot.version> <mysql-connector.version>5.1.39</mysql-connector.version> <druid.version>1.0.28</druid.version> <mybatis-spring-boot.version>1.2.0</mybatis-spring-boot.version> <pagehelper-spring-boot.version>1.1.0</pagehelper-spring-boot.version> <!-- spring boot内置tomcat8,若要配置到外置tomcat中,需指定好外置tomcat版本 <tomcat.version>7.0.67</tomcat.version> --> </properties> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.2.RELEASE</version> <relativePath /> <!-- lookup parent from repository --> </parent> <dependencies> <!-- spring boot的核心启动器,包含了自动配置,日志和YAML --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <!--WEB支持 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <!-- 移除嵌入式tomcat插件\ <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> --> </dependency> <!-- 添加servlet-api的依赖 <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency> --> <!-- 引入了spring boot默认的HTTP引擎tomcat <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> --> <!-- JDBC组件 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>${druid.version}</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>${mybatis-spring-boot.version}</version> </dependency> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>${pagehelper-spring-boot.version}</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.28</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.5</version> </dependency> <dependency> <groupId>org.webjars</groupId> <artifactId>jquery</artifactId> <version>2.1.4</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- 用于测试显示项目内的页面 --> <!-- 添加以下这句会导致项目内jsp页面无法显示 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> --> <!--用于编译jsp --> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>providede</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <scope>provided</scope> </dependency> <!--jsp页面使用jstl标签 --> <dependency> <groupId>javax.servlet.jsp.jstl</groupId> <artifactId>jstl-api</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.7.0</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.1</version> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.1</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.3</version> </dependency> <dependency> <groupId>net.sf.ezmorph</groupId> <artifactId>ezmorph</artifactId> <version>1.0.2</version> </dependency> <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.4</version> <classifier>jdk15</classifier> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.40</version> </dependency> <!-- 支持ueditor --> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.9</version> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.4</version> </dependency> <dependency> <groupId>cn.songxinqiang</groupId> <artifactId>com.baidu.ueditor</artifactId> <version>1.1.2-offical</version> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20140107</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> </dependencies> <build> <finalName>mission</finalName> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.5</version> <configuration> <configurationFile>${basedir}/src/main/resources/generator/generatorConfig.xml</configurationFile> <overwrite>true</overwrite> <verbose>true</verbose> </configuration> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql-connector.version}</version> </dependency> </dependencies> </plugin> </plugins> <resources> <!-- 打包时将jsp文件拷贝到META-INF目录下 --> <resource> <!-- 指定resources插件处理哪个目录下的资源文件 --> <directory>src/main/webapp</directory> <!--注意此次必须要放在此目录下才能被访问到 --> <targetPath>META-INF/resources</targetPath> <includes> <include>**/**</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/**</include> </includes> <filtering>false</filtering> </resource> </resources> </build> </project> application.properties文件: server.port=8081 spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/mission?useUnicode=true&characterEncoding=UTF-8&useSSL=false spring.datasource.username=root spring.datasource.password=system spring.datasource.max-active=10 spring.datasource.max-idle=5 spring.datasource.min-idle=0 mybatis.mapper-locations=classpath:/mybatis/*Mapper.xml mybatis.type-aliases-package=com.qsgw.mission.entity #Set jsp location spring.mvc.view.prefix=/WEB-INF/jsp/ spring.mvc.view.suffix=.jsp application.hello=Hello Angel From application server.servlet.jsp.init-parameters.development=true [/quote] @RequestMapping("/mission") public class PageController { @RequestMapping(value = "/index") public String pageIndex() { return "index"; } @RequestMapping("/show") public String pageShow() { return "show"; } @RequestMapping("/manager") public String pageManager() { return "manager"; } @RequestMapping("/add_new_mission_page") public String pageAddNewMission() { return "add_new_mission"; } 这些资源没有一个可以访问吗?
C.Hang 2017-12-01
  • 打赏
  • 举报
回复
引用 15 楼 hanpoyangtitan 的回复:
[quote=引用 14 楼 chichuhanga 的回复:] [quote=引用 13 楼 hanpoyangtitan 的回复:] [quote=引用 3 楼 chichuhanga 的回复:] [quote=引用 1 楼 hanpoyangtitan 的回复:] 你是用main方法启动的还是放到web容器里了?
在Eclipse里面是main方法启动的,然后打成war包是直接cmd用命令启动的 java -jar mission.jar[/quote] 错误截图上显示没有配置/error 我看了你的代码确实没有映射/error的方法 问题是你怎么访问到error的呢?[/quote] error这个似乎是spring boot自带的,当抛出异常的或者找不到页面的时候,会跳转到spring boot自己设置好的error页面[/quote] 我刚试过,找不到文件会提示jsp找不到,你这个是不是方法报错了? [/quote] 会不会是我pom文件配置有问题,刚接触spring boot,基本上都是按照网上的来的,不知道会不会有错,兄弟能帮我看一下吗? pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.aaa</groupId> <artifactId>mission</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring-boot.version>1.5.2.RELEASE</spring-boot.version> <mysql-connector.version>5.1.39</mysql-connector.version> <druid.version>1.0.28</druid.version> <mybatis-spring-boot.version>1.2.0</mybatis-spring-boot.version> <pagehelper-spring-boot.version>1.1.0</pagehelper-spring-boot.version> <!-- spring boot内置tomcat8,若要配置到外置tomcat中,需指定好外置tomcat版本 <tomcat.version>7.0.67</tomcat.version> --> </properties> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.2.RELEASE</version> <relativePath /> <!-- lookup parent from repository --> </parent> <dependencies> <!-- spring boot的核心启动器,包含了自动配置,日志和YAML --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <!--WEB支持 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <!-- 移除嵌入式tomcat插件\ <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> --> </dependency> <!-- 添加servlet-api的依赖 <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency> --> <!-- 引入了spring boot默认的HTTP引擎tomcat <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> --> <!-- JDBC组件 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>${druid.version}</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>${mybatis-spring-boot.version}</version> </dependency> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>${pagehelper-spring-boot.version}</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.28</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.5</version> </dependency> <dependency> <groupId>org.webjars</groupId> <artifactId>jquery</artifactId> <version>2.1.4</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- 用于测试显示项目内的页面 --> <!-- 添加以下这句会导致项目内jsp页面无法显示 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> --> <!--用于编译jsp --> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>providede</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <scope>provided</scope> </dependency> <!--jsp页面使用jstl标签 --> <dependency> <groupId>javax.servlet.jsp.jstl</groupId> <artifactId>jstl-api</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.7.0</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.1</version> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.1</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.3</version> </dependency> <dependency> <groupId>net.sf.ezmorph</groupId> <artifactId>ezmorph</artifactId> <version>1.0.2</version> </dependency> <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.4</version> <classifier>jdk15</classifier> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.40</version> </dependency> <!-- 支持ueditor --> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.9</version> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.4</version> </dependency> <dependency> <groupId>cn.songxinqiang</groupId> <artifactId>com.baidu.ueditor</artifactId> <version>1.1.2-offical</version> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20140107</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> </dependencies> <build> <finalName>mission</finalName> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.5</version> <configuration> <configurationFile>${basedir}/src/main/resources/generator/generatorConfig.xml</configurationFile> <overwrite>true</overwrite> <verbose>true</verbose> </configuration> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql-connector.version}</version> </dependency> </dependencies> </plugin> </plugins> <resources> <!-- 打包时将jsp文件拷贝到META-INF目录下 --> <resource> <!-- 指定resources插件处理哪个目录下的资源文件 --> <directory>src/main/webapp</directory> <!--注意此次必须要放在此目录下才能被访问到 --> <targetPath>META-INF/resources</targetPath> <includes> <include>**/**</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/**</include> </includes> <filtering>false</filtering> </resource> </resources> </build> </project> application.properties文件: server.port=8081 spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/mission?useUnicode=true&characterEncoding=UTF-8&useSSL=false spring.datasource.username=root spring.datasource.password=system spring.datasource.max-active=10 spring.datasource.max-idle=5 spring.datasource.min-idle=0 mybatis.mapper-locations=classpath:/mybatis/*Mapper.xml mybatis.type-aliases-package=com.qsgw.mission.entity #Set jsp location spring.mvc.view.prefix=/WEB-INF/jsp/ spring.mvc.view.suffix=.jsp application.hello=Hello Angel From application server.servlet.jsp.init-parameters.development=true
什么都不能 2017-12-01
  • 打赏
  • 举报
回复
引用 14 楼 chichuhanga 的回复:
[quote=引用 13 楼 hanpoyangtitan 的回复:]
[quote=引用 3 楼 chichuhanga 的回复:]
[quote=引用 1 楼 hanpoyangtitan 的回复:]
你是用main方法启动的还是放到web容器里了?

在Eclipse里面是main方法启动的,然后打成war包是直接cmd用命令启动的 java -jar mission.jar[/quote]
错误截图上显示没有配置/error 我看了你的代码确实没有映射/error的方法 问题是你怎么访问到error的呢?[/quote]

error这个似乎是spring boot自带的,当抛出异常的或者找不到页面的时候,会跳转到spring boot自己设置好的error页面[/quote]
我刚试过,找不到文件会提示jsp找不到,你这个是不是方法报错了?
C.Hang 2017-12-01
  • 打赏
  • 举报
回复
引用 13 楼 hanpoyangtitan 的回复:
[quote=引用 3 楼 chichuhanga 的回复:] [quote=引用 1 楼 hanpoyangtitan 的回复:] 你是用main方法启动的还是放到web容器里了?
在Eclipse里面是main方法启动的,然后打成war包是直接cmd用命令启动的 java -jar mission.jar[/quote] 错误截图上显示没有配置/error 我看了你的代码确实没有映射/error的方法 问题是你怎么访问到error的呢?[/quote] error这个似乎是spring boot自带的,当抛出异常的或者找不到页面的时候,会跳转到spring boot自己设置好的error页面
什么都不能 2017-12-01
  • 打赏
  • 举报
回复
引用 3 楼 chichuhanga 的回复:
[quote=引用 1 楼 hanpoyangtitan 的回复:] 你是用main方法启动的还是放到web容器里了?
在Eclipse里面是main方法启动的,然后打成war包是直接cmd用命令启动的 java -jar mission.jar[/quote] 错误截图上显示没有配置/error 我看了你的代码确实没有映射/error的方法 问题是你怎么访问到error的呢?
xwn_2016 2017-11-30
  • 打赏
  • 举报
回复
路径没整对吧,没有报错?
加载更多回复(9)
单点登录, SSM框架公共模块 ├── zheng-admin -- 后台管理模板 ├── zheng-ui -- 前台thymeleaf模板[端口:1000] ├── zheng-config -- 配置中心[端口:1001] ├── zheng-upms -- 用户权限管理系统 | ├── zheng-upms-common -- upms系统公共模块 | ├── zheng-upms-dao -- 代码生成模块,无需开发 | ├── zheng-upms-client -- 集成upms依赖包,提供单点认证、授权、统一会话管理 | ├── zheng-upms-rpc-api -- rpc接口包 | ├── zheng-upms-rpc-service -- rpc服务提供者 | └── zheng-upms-server -- 用户权限系统及SSO服务端[端口:1111] ├── zheng-cms -- 内容管理系统 | ├── zheng-cms-common -- cms系统公共模块 | ├── zheng-cms-dao -- 代码生成模块,无需开发 | ├── zheng-cms-rpc-api -- rpc接口包 | ├── zheng-cms-rpc-service -- rpc服务提供者 | ├── zheng-cms-search -- 搜索服务[端口:2221] | ├── zheng-cms-admin -- 后台管理[端口:2222] | ├── zheng-cms-job -- 消息队列、任务调度等[端口:2223] | └── zheng-cms-web -- 网站前台[端口:2224] ├── zheng-pay -- 支付系统 | ├── zheng-pay-common -- pay系统公共模块 | ├── zheng-pay-dao -- 代码生成模块,无需开发 | ├── zheng-pay-rpc-api -- rpc接口包 | ├── zheng-pay-rpc-service -- rpc服务提供者 | ├── zheng-pay-sdk -- 开发工具包 | ├── zheng-pay-admin -- 后台管理[端口:3331] | └── zheng-pay-web -- 演示示例[端口:3332] ├── zheng-ucenter -- 用户系统(包括第三方登录) | ├── zheng-ucenter-common -- ucenter系统公共模块 | ├── zheng-ucenter-dao -- 代码生成模块,无需开发 | ├── zheng-ucenter-rpc-api -- rpc接口包 | ├── zheng-ucenter-rpc-service -- rpc服务提供者 | └── zheng-ucenter-web -- 网站前台[端口:4441] ├── zheng-wechat -- 微信系统 | ├── zheng-wechat-mp -- 微信公众号管理系统 | | ├── zheng-wechat-mp-dao -- 代码生成模块,无需开发 | | ├── zheng-wechat-mp-service -- 业务逻辑 | | └── zheng-wechat-mp-admin -- 后台管理[端口:5551] | └── zheng-ucenter-app -- 微信小程序后台 ├── zheng-api -- API接口总线系统 | ├── zheng-api-common -- api系统公共模块 | ├── zheng-api-rpc-api -- rpc接口包 | ├── zheng-api-rpc-service -- rpc服务提供者 | └── zheng-api-server -- api系统服务端[端口:6666] ├── zheng-oss -- 对象存储系统 | ├── zheng-oss-sdk -- 开发工具包 | ├── zheng-oss-web -- 前台接口[端口:7771] | └── zheng-oss-admin -- 后台管理[端口:7772] ├── zheng-shop -- 电子商务系统 ├── zheng-im -- 即时通讯系统 ├── zheng-oa -- 办公自动化系统 ├── zheng-eoms -- 运维系统 └── zheng-demo -- 示例模块(包含一些示例代码等) ├── zheng-demo-rpc-api -- rpc接口包 ├── zheng-demo-rpc-service -- rpc服务提供者 └── zheng-demo-web -- 演示示例[端口:8888] ``` ### 技术选型 #### 后端技术: 技术 | 名称 | 官网 ----|------|---- Spring Framework | 容器 | [http://projects.spring.io/spring-framework/](http://projects.spring.io/spring-framework/) SpringMVC | MVC框架 | [http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc](http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc) Apache Shiro | 安全框架 | [http://shiro.apache.org/](http://shiro.apache.org/) Spring session | 分布式Session管理 | [http://projects.spring.io/spring-session/](http://projects.spring.io/spring-session/) MyBatis | ORM框架 | [http://www.mybatis.org/mybatis-3/zh/index.html](http://www.mybatis.org/mybatis-3/zh/index.html) MyBatis Generator | 代码生成 | [http://www.mybatis.org/generator/index.html](http://www.mybatis.org/generator/index.html) PageHelper | MyBatis物理分页插件 | [http://git.oschina.net/free/Mybatis_PageHelper](http://git.oschina.net/free/Mybatis_PageHelper) Druid | 数据库连接池 | [https://github.com/alibaba/druid](https://github.com/alibaba/druid) FluentValidator | 校验框架 | [https://github.com/neoremind/fluent-validator](https://github.com/neoremind/fluent-validator) Thymeleaf | 模板引擎 | [http://www.thymeleaf.org/](http://www.thymeleaf.org/) Velocity | 模板引擎 | [http://velocity.apache.org/](http://velocity.apache.org/) ZooKeeper | 分布式协调服务 | [http://zookeeper.apache.org/](http://zookeeper.apache.org/) Dubbo | 分布式服务框架 | [http://dubbo.io/](http://dubbo.io/) TBSchedule & elastic-job | 分布式调度框架 | [https://github.com/dangdangdotcom/elastic-job](https://github.com/dangdangdotcom/elastic-job) Redis | 分布式缓存数据库 | [https://redis.io/](https://redis.io/) Solr & Elasticsearch | 分布式全文搜索引擎 | [http://lucene.apache.org/solr/](http://lucene.apache.org/solr/) [https://www.elastic.co/](https://www.elastic.co/) Quartz | 作业调度框架 | [http://www.quartz-scheduler.org/](http://www.quartz-scheduler.org/) Ehcache | 进程内缓存框架 | [http://www.ehcache.org/](http://www.ehcache.org/) ActiveMQ | 消息队列 | [http://activemq.apache.org/](http://activemq.apache.org/) JStorm | 实时流式计算框架 | [http://jstorm.io/](http://jstorm.io/) FastDFS | 分布式文件系统 | [https://github.com/happyfish100/fastdfs](https://github.com/happyfish100/fastdfs) Log4J | 日志组件 | [http://logging.apache.org/log4j/1.2/](http://logging.apache.org/log4j/1.2/) Swagger2 | 接口测试框架 | [http://swagger.io/](http://swagger.io/) sequence | 分布式高效ID生产 | [http://git.oschina.net/yu120/sequence](http://git.oschina.net/yu120/sequence) AliOSS & Qiniu & QcloudCOS | 云存储 | [https://www.aliyun.com/product/oss/](https://www.aliyun.com/product/oss/) [http://www.qiniu.com/](http://www.qiniu.com/) [https://www.qcloud.com/product/cos](https://www.qcloud.com/product/cos) Protobuf & json | 数据序列化 | [https://github.com/google/protobuf](https://github.com/google/protobuf) Jenkins | 持续集成工具 | [https://jenkins.io/index.html](https://jenkins.io/index.html) Maven | 项目构建管理 | [http://maven.apache.org/](http://maven.apache.org/) #### 前端技术: 技术 | 名称 | 官网 ----|------|---- jQuery | 函式库 | [http://jquery.com/](http://jquery.com/) Bootstrap | 前端框架 | [http://getbootstrap.com/](http://getbootstrap.com/) Bootstrap-table | Bootstrap数据表格 | [http://bootstrap-table.wenzhixin.net.cn/](http://bootstrap-table.wenzhixin.net.cn/) Font-awesome | 字体图标 | [http://fontawesome.io/](http://fontawesome.io/) material-design-iconic-font | 字体图标 | [https://github.com/zavoloklom/material-design-iconic-font](https://github.com/zavoloklom/material-design-iconic-font) Waves | 点击效果插件 | [https://github.com/fians/Waves](https://github.com/fians/Waves) zTree | 树插件 | [http://www.treejs.cn/v3/](http://www.treejs.cn/v3/) Select2 | 选择框插件 | [https://github.com/select2/select2](https://github.com/select2/select2) jquery-confirm | 弹出窗口插件 | [https://github.com/craftpip/jquery-confirm](https://github.com/craftpip/jquery-confirm) jQuery EasyUI | 基于jQuery的UI插件集合体 | [http://www.jeasyui.com](http://www.jeasyui.com) React | 界面构建框架 | [https://github.com/facebook/react](https://github.com/facebook/react) Editor.md | Markdown编辑器 | [https://github.com/pandao/editor.md](https://github.com/pandao/editor.md) zhengAdmin | 后台管理系统模板 | [https://github.com/shuzheng/zhengAdmin](https://github.com/shuzheng/zhengAdmin) autoMail | 邮箱地址自动补全插件 | [https://github.com/shuzheng/autoMail](https://github.com/shuzheng/autoMail) zheng.jprogress.js | 加载进度条插件 | [https://github.com/shuzheng/zheng.jprogress.js](https://github.com/shuzheng/zheng.jprogress.js) zheng.jtotop.js | 返回顶部插件 | [https://github.com/shuzheng/zheng.jtotop.js](https://github.com/shuzheng/zheng.jtotop.js) #### 架构图 ![架构图](project-bootstrap/architect.png) #### 模块依赖 ![模块依赖](project-bootstrap/project.png) #### 模块介绍 > zheng-common Spring+SpringMVC+Mybatis框架集成公共模块,包括公共配置、MybatisGenerator扩展插件、通用BaseService、工具类等。 > zheng-admin 基于bootstrap实现的响应式Material Design风格的通用后台管理系统,`zheng`项目所有后台系统都是使用该模块界面作为前端展示。 > zheng-ui 各个子系统前台thymeleaf模板,前端资源模块,使用nginx代理,实现动静分离。 > zheng-upms 本系统是基于RBAC授权和基于用户授权的细粒度权限控制通用平台,并提供单点登录、会话管理和日志管理。接入的系统可自由定义组织、角色、权限、资源等。用户权限=所拥有角色权限合集+用户加权限-用户减权限,优先级:用户减权限>用户加权限>角色权限 > zheng-oss 文件存储系统,提供四种方案: - **阿里云** OSS - **腾讯云** COS - **七牛云** - 本地分布式存储 ![阿里云OSS](project-bootstrap/aliyun-oss-post-callback.png) > zheng-api 服务网关,对外暴露统一规范的接口和包装响应结果,包括各个子系统的交互接口、对外开放接口、开发加密接口、接口文档等服务,可在该模块支持验签、鉴权、路由、限流、监控、容错、日志等功能。示例图: ![API网关](project-bootstrap/gateway_config.png) > zheng-cms 内容管理系统:支持多标签、多类目、强大评论的内容管理,有基本单页展示,菜单管理,系统设置等功能。 > zheng-pay - 一站式支付解决方案,统一下单接口,支持支付宝、微信、网银等多种支付方式。不涉及业务的纯粹的支付平台。 - 统一下单(统一下单接口、统一扫码)、订单管理、数据分析、财务报表、商户管理、渠道管理、对账系统、系统监控。 ![统一扫码支付](project-bootstrap/zheng-pay.png) > zheng-ucenter 通用用户管理系统, 实现最常用的用户注册、登录、资料管理、个人中心、第三方登录等基本需求,支持扩展二次开发。 > zheng-wechat-mp 微信公众号管理平台,除实现官网后台自动回复、菜单管理、素材管理、用户管理、消息群发等基础功能外,还有二维码推广、营销活动、微网站、会员卡、优惠券等。 > zheng-wechat-app 微信小程序后台 ## 环境搭建(QQ群内有“zheng环境搭建和系统部署文档.doc”) #### 开发工具: - MySql: 数据库 - jetty: 开发服务器 - Tomcat: 应用服务器 - SVN|Git: 版本管理 - Nginx: 反向代理服务器 - Varnish: HTTP加速器 - IntelliJ IDEA: 开发IDE - PowerDesigner: 建模工具 - Navicat for MySQL: 数据库客户端 #### 开发环境: - Jdk7+ - Mysql5.5+ - Redis - Zookeeper - ActiveMQ - Dubbo-admin - Dubbo-monitor ### 工具安装 环境搭建和系统部署文档(作者:小兵,QQ群共享提供下载) ### 资源下载 - JDK7 [http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html](http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html "JDK7") - Maven [http://maven.apache.org/download.cgi](http://maven.apache.org/download.cgi "Maven") - Redis [https://redis.io/download](https://redis.io/download "Redis") - ActiveMQ [http://activemq.apache.org/download-archives.html](http://activemq.apache.org/download-archives.html "ActiveMQ") - ZooKeeper [http://www.apache.org/dyn/closer.cgi/zookeeper/](http://www.apache.org/dyn/closer.cgi/zookeeper/ "ZooKeeper") - Dubbo [http://dubbo.io/Download-zh.htm](http://dubbo.io/Download-zh.htm "Dubbo") - Elastic Stack [https://www.elastic.co/downloads](https://www.elastic.co/downloads "Elastic Stack") - Nginx [http://nginx.org/en/download.html](http://nginx.org/en/download.html "Nginx") - Jenkins [http://updates.jenkins-ci.org/download/war/](http://updates.jenkins-ci.org/download/war/ "Jenkins") - dubbo-admin-2.5.3 [http://download.csdn.net/detail/shuzheng5201314/9733652](http://download.csdn.net/detail/shuzheng5201314/9733652 "dubbo-admin-2.5.3") - dubbo-admin-2.5.4-SNAPSHOT-jdk8 [http://download.csdn.net/detail/shuzheng5201314/9733657](http://download.csdn.net/detail/shuzheng5201314/9733657 "dubbo-admin-2.5.4-SNAPSHOT-jdk8") - 更多资源请加QQ群 ## 开发指南: - 1、本机安装Jdk7、Mysql、Redis、Zookeeper、ActiveMQ并**启动相关服务**,使用默认配置默认端口即可 - 2、克隆源代码到本地并打开,**推荐使用IntelliJ IDEA**,本地编译并安装到本地maven仓库 ### 修改本地Host - 127.0.0.1 ui.zhangshuzheng.cn - 127.0.0.1 upms.zhangshuzheng.cn - 127.0.0.1 cms.zhangshuzheng.cn - 127.0.0.1 pay.zhangshuzheng.cn - 127.0.0.1 ucenter.zhangshuzheng.cn - 127.0.0.1 wechat.zhangshuzheng.cn - 127.0.0.1 api.zhangshuzheng.cn - 127.0.0.1 oss.zhangshuzheng.cn - 127.0.0.1 config.zhangshuzheng.cn - 127.0.0.1 zkserver - 127.0.0.1 rdserver - 127.0.0.1 dbserver - 127.0.0.1 mqserver ### 编译流程 maven编译安装zheng/pom.xml文件即可 ### 启动顺序(后台) > 准备工作 - 新建zheng数据库,导入project-datamodel文件夹下的zheng.sql - 修改各dao模块和rpc-service模块的redis.properties、jdbc.properties、generator.properties数据库连接等配置信息,其中master.redis.password、master.jdbc.password、slave.jdbc.password、generator.jdbc.password密码值使用了AES加密,请使用com.zheng.common.util.AESUtil工具类修改这些值 - 启动Zookeeper、Redis、ActiveMQ、Nginx(配置文件参考project-tools/nginx下的*.conf文件) > **zheng-upms** - 首先启动 zheng-upms-rpc-service(直接运行src目录下的ZhengUpmsRpcServiceApplication#main方法启动) => zheng-upms-server(jetty),然后按需启动对应子系统xxx的zheng-xxx-rpc-service(main方法) => zheng-xxx-webapp(jetty) ![启动演示](project-bootstrap/start.png) - 访问 [http://upms.zhangshuzheng.cn:1111/](http://upms.zhangshuzheng.cn:1111/ "统一后台地址"),子系统菜单已经配置到zheng-upms权限中,不用直接访问子系统,默认帐号密码:admin/123456 - 登录成功后,可在右上角切换已注册系统访问 > **zheng-cms** - zheng-cms-admin:启动ActiveMQ-启动 => 启动zheng-rpc-service => 启动zheng-cms-admin - zheng-cms-web:启动nginx代理zheng-ui静态资源,配置文件可参考 [nginx.conf](http://git.oschina.net/shuzheng/zheng/attach_files) > **zheng-oss** - 首先启动zheng-oss-web服务 - 开发阶段,如果zheng-oss-web没有公网域名,推荐使用`ngrok`内网穿透工具,为开发环境提供公网域名,实现上传回调 - 启动nginx代理zheng-ui静态资源 ### 开发演示(QQ群内有“zheng十分钟视频:从检出到启动.wmv”) - 创建数据表(建议使用PowerDesigner) - 直接运行对应项目dao模块中的generator.main(),可自动生成单表的CRUD功能和对应的model、example、mapper、service代码 - 生成的model和example均已实现Serializable接口,支持分布式 - 已包含抽象类BaseServiceImpl,只需要继承抽象类并传入泛型参数,即可默认实现mapper接口所有方法,特殊需求直接扩展即可 - BaseServiceImpl默认已实现四种根据条件分页接口 - selectByExampleWithBLOBsForStartPage() - selectByExampleForStartPage() - selectByExampleWithBLOBsForOffsetPage() - selectByExampleForOffsetPage() - BaseServiceImpl方法根据读写操作自动切换主从数据源,继承的扩展接口,可手动通过`DynamicDataSource.setDataSource(DataSourceEnum.XXX.getName())`指定数据源 - 启动流程:优先rcp-service服务提供者,再启动其他webapp - 扩展流程:可扩展和拆分rpc-api和rpc-service模块,可按微服务拆分或场景拆分 ### 部署方式(QQ群内有“zheng十分钟视频:从打包到linux服务器部署.wmv”) - war包项目:使用tomcat等web容器启动 - rpc-service服务提供者jar包:将打包后的zheng-xxx-rpc-service-assembly.tar.gz文件解压,使用bin目录的管理脚本运行即可,支持优雅停机。 ### 框架规范约定 约定优于配置(convention over configuration),此框架约定了很多编程规范,下面一一列举: ``` - service类,需要在叫名`service`的包下,并以`Service`结尾,如`CmsArticleServiceImpl` - controller类,需要在以`controller`结尾的包下,类名以Controller结尾,如`CmsArticleController.java`,并继承`BaseController` - spring task类,需要在叫名`task`的包下,并以`Task`结尾,如`TestTask.java` - mapper.xml,需要在名叫`mapper`的包下,并以`Mapper.xml`结尾,如`CmsArticleMapper.xml` - mapper接口,需要在名叫`mapper`的包下,并以`Mapper`结尾,如`CmsArticleMapper.java` - model实体类,需要在名叫`model`的包下,命名规则为数据表转驼峰规则,如`CmsArticle.java` - spring配置文件,命名规则为`applicationContext-*.xml` - 类名:首字母大写驼峰规则;方法名:首字母小写驼峰规则;常量:全大写;变量:首字母小写驼峰规则,尽量非缩写 - springmvc配置加到对应模块的`springMVC-servlet.xml`文件里 - 配置文件放到`src/main/resources`目录下 - 静态资源文件放到`src/main/webapp/resources`目录下 - jsp文件,需要在`/WEB-INF/jsp`目录下 - `RequestMapping`和返回物理试图路径的url尽量写全路径,如:`@RequestMapping("/manage")`、`return "/manage/index"` - `RequestMapping`指定method - 模块命名为`项目`-`子项目`-`业务`,如`zheng-cms-admin` - 数据表命名为:`子系统`_`表`,如`cms_article` - 更多规范,参考[[阿里巴巴Java开发手册] http://git.oschina.net/shuzheng/zheng/attach_files ``` ## 演示地址 演示地址: [http://upms.zhangshuzheng.cn/](http://47.93.195.63/zheng-upms-server/sso/login?backurl=http://47.93.195.63/zheng-upms-server/manage/index "演示地址") ### 预览图 ![idea](project-bootstrap/idea.png) ![login](project-bootstrap/zheng-login.png) ![upms](project-bootstrap/zheng-upms.png) ![cms](project-bootstrap/zheng-cms.png) ![swagger](project-bootstrap/api.png) ### 数据模型 ![数据库模型](project-datamodel/zheng.png) ### 拓扑图 ![拓扑图](project-bootstrap/distributedSystem.png) ### 开发进度 ![开发进度](project-bootstrap/progress.png) ### 参与开发 首先谢谢大家支持,如果你希望参与开发,欢迎通过[Github](https://github.com/shuzheng/zheng "Github")上fork本项目,并Pull Request您的commit。 ### 常见问题 - Eclipse下,dubbo找不到dubbo.xsd报错,不影响使用,如果要解决,可参考 [http://blog.csdn.net/gjldwz/article/details/50555922](http://blog.csdn.net/gjldwz/article/details/50555922) - 报zheng-xxx.jar包找不到,请按照文档编译顺序,将源代码编译并安装到本地maven仓库 - zheng-cms-admin启动卡住:因为没有启动activemq - zheng-upms-server访问报session不存在:因为没有启动redis服务 - 界面没有样式:因为zheng-admin没有编译安装到本地仓库 ## 附件 ### 优秀文章和博客 - [创业互联网公司如何搭建自己的技术框架](http://shuzheng5201314.iteye.com/blog/2330151 "创业互联网公司如何搭建自己的技术框架") - [微服务实战](https://segmentfault.com/a/1190000004634172 "微服务实战") - [单点登录原理与简单实现](http://shuzheng5201314.iteye.com/blog/2343910 "单点登录原理与简单实现") - [ITeye论坛关于权限控制的讨论](http://www.iteye.com/magazines/82 "ITeye论坛关于权限控制的讨论") - [RBAC新解:基于资源的权限管理(Resource-Based Access Control)](http://globeeip.iteye.com/blog/1236167 "RBAC新解:基于资源的权限管理(Resource-Based Access Control)") - [网站架构经验随笔](http://jinnianshilongnian.iteye.com/blog/2289904 "网站架构经验随笔") - [支付系统架构](http://shuzheng5201314.iteye.com/blog/2355431 "支付系统架构") - [Spring整合JMS](http://elim.iteye.com/blog/1893038 "Spring整合JMS") - [跟我学Shiro目录贴](http://jinnianshilongnian.iteye.com/blog/2018398 "跟我学Shiro目录贴") - [跟我学SpringMVC目录汇总贴](http://jinnianshilongnian.iteye.com/blog/1752171 "跟我学SpringMVC目录汇总贴") - [跟我学spring3 目录贴](http://jinnianshilongnian.iteye.com/blog/1482071 "跟我学spring3 目录贴") - [跟我学OpenResty(Nginx+Lua)开发目录贴](http://jinnianshilongnian.iteye.com/blog/2190344 "跟我学OpenResty(Nginx+Lua)开发目录贴") - [Redis中文网](http://www.redis.net.cn/ "Redis中文网") - [读懂Redis并配置主从集群及高可用部署](http://mp.weixin.qq.com/s?__biz=MzIxNTYzOTQ0Ng==&mid=2247483668&idx=1&sn=cd31574877d38cf7ff9c047b86c9bf23&chksm=979475eda0e3fcfb6b5006bcd19c5a838eca9e369252847dbdf97820bf418201dd75c1dadda3&mpshare=1&scene=23&srcid=0117KUiiITwi2ETRan16xRVg#rd "读懂Redis并配置主从集群及高可用部署") - [Redis哨兵-实现Redis高可用](http://redis.majunwei.com/topics/sentinel.html "Redis哨兵-实现Redis高可用") - [ELK(ElasticSearch, Logstash, Kibana)搭建实时日志分析平台](http://www.open-open.com/lib/view/open1451801542042.html "ELK(ElasticSearch, Logstash, Kibana)搭建实时日志分析平台") - [Nginx基本功能极速入门](http://xxgblog.com/2015/05/17/nginx-start/ "Nginx基本功能极速入门") - [mybatis-genarator 自定义插件](https://my.oschina.net/alexgaoyh/blog/702791 "mybatis-genarator 自定义插件") - [Elasticsearch权威指南(中文版)](https://es.xiaoleilu.com/510_Deployment/20_hardware.html "Elasticsearch权威指南(中文版)") - [springMVC对简单对象、Set、List、Map的数据绑定和常见问题.](http://blog.csdn.net/z_dendy/article/details/12648641 "springMVC对简单对象、Set、List、Map的数据绑定和常见问题.") - [如何细粒度地控制你的MyBatis二级缓存](http://blog.csdn.net/luanlouis/article/details/41800511 "如何细粒度地控制你的MyBatis二级缓存") - [做个男人,做个成熟的男人,做个有城府的男人](http://shuzheng5201314.iteye.com/blog/1387820 "做个男人,做个成熟的男人,做个有城府的男人") ### 在线小工具 - [在线Cron表达式生成器](http://cron.qqe2.com/ "在线Cron表达式生成器") - [在线工具 - 程序员的工具箱](http://tool.lu/ "在线工具 - 程序员的工具箱") ### 在线文档 - [JDK7英文文档](http://tool.oschina.net/apidocs/apidoc?api=jdk_7u4 "JDK7英文文档") - [Spring4.x文档](http://spring.oschina.mopaas.com/ "Spring4.x文档") - [Mybatis3官网](http://www.mybatis.org/mybatis-3/zh/index.html "Mybatis3官网") - [Dubbo官网](http://dubbo.io/ "Dubbo官网") - [Nginx中文文档](http://tool.oschina.net/apidocs/apidoc?api=nginx-zh "Nginx中文文档") - [Freemarker在线手册](http://freemarker.foofun.cn/ "Freemarker在线中文手册") - [Velocity在线手册](http://velocity.apache.org/engine/devel/developer-guide.html "Velocity在线手册") - [Bootstrap在线手册](http://www.bootcss.com/ "Bootstrap在线手册") - [Git官网中文文档](https://git-scm.com/book/zh/v2 "Git官网中文文档") - [Thymeleaf](http://www.thymeleaf.org/doc/tutorials/3.0/thymeleafspring.html "Thymeleaf") ## 许可证 [MIT](LICENSE "MIT")
1.[今日课程内容总览] Maven--***** 介绍 优点 用maven创建一个项目, 用maven创建一个ssm项目,每一层的代码分开,把一个项目拆解成多个项目 2.[今日包含笔记] maven介绍: Eclise: 缺点: Jar包: 版本管理,解决jar包冲突:删除老的jar包,保留新的jar包 不同的项目,jar包要复制一份;Users Library 羡慕yum的好处,安装软件,自动下载,自动验证,自动安装,自动测试;镜像网站 Jar包的依赖: 致命的缺点:现象: 每一个项目都有前台(广大网民)和后台(管理员看的),后台的功能远远的大于>前台的功能;迭代升级;每次升级都要重启tomcat;将tomcat做很多个备份(10个),为了nginx转发;前台:访问比较大,管理员访问量比较小; 问题: 每次升级,10个tomcat都升级一次 后台的升级频繁要比前台频繁;升级10次,9次改的是后台的代码,只有一次是前台的代码 解决方案: 是将前台(广大网民看的页面)的代码和后台(管理员)的代码要分开,将原来的一个项目分别放到两个web项目;一个web项目一个tomcat;好处:更新的时候如果更新后台(管理员),只需要重启后台的tomcat(服务); 折成两个项目以后的缺点:Service以下的代码重复; 将Service层以下的代码放到一个新创建的java项目中,在部署的时候将Service(java项目)打成一个jar包,分别放到两个web服务中;编译的时候让web项目依赖与Service(java项目)_source folder;配置麻烦,项目与项目之间的依赖头脑得相当清晰 这个缺点Maven解决了; 请听今天的内容 拆分前:图一 拆分后是图二 3. 介绍 官网:http://maven.apache.org/download.cgi 目录介绍: Bin:二进制文件 Boot:引导,启动 Conf:配置文件 Lib:jar包 README.txt:读我 3.1.修改配置文件的内容 路径:%MAVEN_HOME%\conf\settings.xml 配置文件代码: d:/repo alimaven aliyun maven http://maven.aliyun.com/nexus/content/groups/public/ central 注意: 千万不要将文档中的setting的内容全部替换到maven中的内容,要对比着修改,保留原来的; 只修改本地仓库,和下载镜像(源) 3.2.Eclipse Maven的配置 每打开一个新的工作空间,要配置一下Maven,然后再写代码 3.3.创建Maven项目 右击创建一个maven project Packing:有三种: Jar:java项目, War:web项目 Pom:文件夹,jar和war文件,mavenProject:一个项目,可以放jar和war包,通过pom,一般新创建的maven Project是POM 3.4.创建一个Maven Model 最外面的项目是MavenProject,其它的全部是Maven Model 3.4.1.创建JAR 目录介绍: Mvn-jar |-->Src:源码:java代码 |-->|-->main:代码:除测试以外的代码:junit |-->|-->main|-->java:代码 |-->|-->main|--

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧