|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 3 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| 4 | + <modelVersion>4.0.0</modelVersion> |
| 5 | + |
| 6 | + <groupId>com.answer</groupId> |
| 7 | + <artifactId>springboot-mybatis-web</artifactId> |
| 8 | + <version>1.0.0</version> |
| 9 | + <packaging>jar</packaging> |
| 10 | + |
| 11 | + <name>springboot-mybatis-web</name> |
| 12 | + <description>Demo project for Spring Boot</description> |
| 13 | + |
| 14 | + <parent> |
| 15 | + <groupId>org.springframework.boot</groupId> |
| 16 | + <artifactId>spring-boot-starter-parent</artifactId> |
| 17 | + <version>2.0.5.RELEASE</version> |
| 18 | + <relativePath/> <!-- lookup parent from repository --> |
| 19 | + </parent> |
| 20 | + |
| 21 | + <properties> |
| 22 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| 23 | + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> |
| 24 | + <java.version>1.8</java.version> |
| 25 | + </properties> |
| 26 | + |
| 27 | + <dependencies> |
| 28 | + <dependency> |
| 29 | + <groupId>org.springframework.boot</groupId> |
| 30 | + <artifactId>spring-boot-starter-web</artifactId> |
| 31 | + </dependency> |
| 32 | + <dependency> |
| 33 | + <groupId>org.mybatis.spring.boot</groupId> |
| 34 | + <artifactId>mybatis-spring-boot-starter</artifactId> |
| 35 | + <version>1.3.2</version> |
| 36 | + </dependency> |
| 37 | + |
| 38 | + <dependency> |
| 39 | + <groupId>mysql</groupId> |
| 40 | + <artifactId>mysql-connector-java</artifactId> |
| 41 | + </dependency> |
| 42 | + <dependency> |
| 43 | + <groupId>org.springframework.boot</groupId> |
| 44 | + <artifactId>spring-boot-starter-test</artifactId> |
| 45 | + <scope>test</scope> |
| 46 | + </dependency> |
| 47 | + |
| 48 | + <!-- Web for Jsp need start --> |
| 49 | + <dependency> |
| 50 | + <groupId>javax.servlet</groupId> |
| 51 | + <artifactId>jstl</artifactId> |
| 52 | + </dependency> |
| 53 | + <dependency> |
| 54 | + <groupId>org.springframework.boot</groupId> |
| 55 | + <artifactId>spring-boot-starter-tomcat</artifactId> |
| 56 | + </dependency> |
| 57 | + <dependency> |
| 58 | + <groupId>org.apache.tomcat.embed</groupId> |
| 59 | + <artifactId>tomcat-embed-jasper</artifactId> |
| 60 | + </dependency> |
| 61 | + <dependency> |
| 62 | + <groupId>javax.servlet</groupId> |
| 63 | + <artifactId>javax.servlet-api</artifactId> |
| 64 | + </dependency> |
| 65 | + <!-- Web for Jsp need end --> |
| 66 | + |
| 67 | + </dependencies> |
| 68 | + |
| 69 | + <build> |
| 70 | + <plugins> |
| 71 | + <plugin> |
| 72 | + <groupId>org.springframework.boot</groupId> |
| 73 | + <artifactId>spring-boot-maven-plugin</artifactId> |
| 74 | + <version>1.4.2.RELEASE</version> |
| 75 | + </plugin> |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + <!-- Docker Maven插件 --> |
| 80 | + <plugin> |
| 81 | + <groupId>com.spotify</groupId> |
| 82 | + <artifactId>docker-maven-plugin</artifactId> |
| 83 | + <!-- Docker镜像相关的配置信息 --> |
| 84 | + <configuration> |
| 85 | + <!-- 镜像名, 这里用工程名 --> |
| 86 | + <imageName>${project.artifactId}</imageName> |
| 87 | + <!-- 镜像版本号, 可设置多个, 如果不是设为latest, 则会生成两个镜像, 即设置的版本号和latest --> |
| 88 | + <imageTags> |
| 89 | + <imageTag>latest</imageTag> |
| 90 | + <!--<imageTag>${project.version}</imageTag>--> |
| 91 | + </imageTags> |
| 92 | + <!-- 镜像的FROM, 使用java官方镜像 | 构建镜像时需要的基础镜像, 类似于DockerFile的From --> |
| 93 | + <baseImage>java:8</baseImage> |
| 94 | + <!--该镜像的容器启动后, 直接运行spring boot工程 | 容器启动时执行的命令 --> |
| 95 | + <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint> |
| 96 | + <!--<volumes> |
| 97 | + <volume>/home</volume> |
| 98 | + </volumes> |
| 99 | + --> |
| 100 | + <!-- 设置环境变量 | 类似于DockerDile的ENV --> |
| 101 | + <env> |
| 102 | + <MYSQL_IP>119.23.XXX.XXX</MYSQL_IP> |
| 103 | + <MYSQL_PORT>3306</MYSQL_PORT> |
| 104 | + <MYSQL_DB>answer</MYSQL_DB> |
| 105 | + <MYSQL_UNAME>root</MYSQL_UNAME> |
| 106 | + <MYSQL_PASSWD>123456</MYSQL_PASSWD> |
| 107 | + </env> |
| 108 | + <!-- 设定容器向外部暴露的端口 --> |
| 109 | + <exposes> |
| 110 | + <expose>8088</expose> |
| 111 | + </exposes> |
| 112 | + <!-- 这里是复制 jar 包到 docker 容器指定目录配置, 相当于DockerFile的ADD --> |
| 113 | + <resources> |
| 114 | + <resource> |
| 115 | + <targetPath>/</targetPath> |
| 116 | + <directory>${project.build.directory}</directory> |
| 117 | + <include>${project.build.finalName}.jar</include> |
| 118 | + </resource> |
| 119 | + </resources> |
| 120 | + </configuration> |
| 121 | + </plugin> |
| 122 | + </plugins> |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | + <!-- 解决打包时访问不了JSP问题 --> |
| 127 | + <resources> |
| 128 | + <!-- 打包时将jsp文件拷贝到META-INF目录下--> |
| 129 | + <resource> |
| 130 | + <!-- 指定resources插件处理哪个目录下的资源文件 --> |
| 131 | + <directory>src/main/webapp</directory> |
| 132 | + <!--注意此次必须要放在此目录下才能被访问到--> |
| 133 | + <targetPath>META-INF/resources</targetPath> |
| 134 | + <includes> |
| 135 | + <include>**/**</include> |
| 136 | + </includes> |
| 137 | + </resource> |
| 138 | + <resource> |
| 139 | + <directory>src/main/resources</directory> |
| 140 | + <includes> |
| 141 | + <include>**/**</include> |
| 142 | + </includes> |
| 143 | + <filtering>false</filtering> |
| 144 | + </resource> |
| 145 | + <resource> |
| 146 | + <directory>src/main/java</directory> |
| 147 | + <excludes> |
| 148 | + <exclude>**/*.java</exclude> |
| 149 | + </excludes> |
| 150 | + </resource> |
| 151 | + </resources> |
| 152 | + </build> |
| 153 | + |
| 154 | + |
| 155 | +</project> |
0 commit comments