项目:SpringBoot+maven分模块(注意: 这是创建了项目的时候有选中了maven)

Linux nexus repository搭建maven私服_spring boot

 

首先要在IDEA进行打包, 然后才在Linux进行部署运行

在此之前有两个需要注意的地方,也就是父项目(goods_parent)和web项目(goods_web)的Pom.xml

 步骤一:查看父项目Pom.xml中是否有 <build>相应的打包依赖,如果有的话删除,否则可能会报错,导致打包失败

如:我的Pom.xml 是没有build的

<?xml version="1.0" encoding="UTF-8"?>
<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.czxy</groupId>
	<!-- 仅需要修改项目名 -->
    <artifactId>goods_parent</artifactId>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>goods_domain</module>
        <module>goods_service</module>
        <module>goods_dao</module>
        <module>goods_web</module>
    </modules>

    <packaging>pom</packaging>

    <!-- 父工程 -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <!-- 引入SSM整合SpringBoot jar包 -->
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <mybatis.starter.version>1.3.2</mybatis.starter.version>
        <mapper.starter.version>2.0.2</mapper.starter.version>
        <mysql.version>5.1.32</mysql.version>
        <pageHelper.starter.version>1.2.5</pageHelper.starter.version>
        <durid.starter.version>1.1.10</durid.starter.version>
    </properties>
    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <!-- mybatis启动器 -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>${mybatis.starter.version}</version>
        </dependency>
        <!-- 通用Mapper启动器 -->
        <dependency>
            <groupId>tk.mybatis</groupId>
            <artifactId>mapper-spring-boot-starter</artifactId>
            <version>${mapper.starter.version}</version>
        </dependency>
        <!-- 分页助手启动器 -->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>${pageHelper.starter.version}</version>
        </dependency>
        <!-- mysql驱动 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>
        <!-- Druid连接池 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${durid.starter.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
        </dependency>
        <!-- jstl -->
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
    </dependencies>

 

 

 

步骤二:查看Web项目中,是否有 <build>相应的打包依赖
<build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <mainClass>com.czxy.goods.MySpringBootStarter</mainClass>
        </configuration>
      </plugin>
    </plugins>
    <resources>
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.xml</include>
        </includes>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
        <includes>
          <include>**/*.*</include>
        </includes>
      </resource>
      <!-- 打包时将jsp文件拷贝到META-INF目录下 -->
      <resource>
        <!-- 指定resources插件处理哪个目录下的资源文件 -->
        <directory>src/main/webapp</directory>
        <!--注意此次必须要放在此目录下才能被访问到 -->
        <targetPath>META-INF/resources</targetPath>
        <includes>
          <include>**/*.*</include>
        </includes>
      </resource>
    </resources>
  </build>

 

Pom.xml

<?xml version="1.0" encoding="UTF-8"?>

<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">
  <parent>
    <artifactId>goods_parent</artifactId>
    <groupId>com.czxy</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>goods_web</artifactId>
  <packaging>war</packaging>

  <dependencies>
    <dependency>
      <groupId>com.czxy</groupId>
      <artifactId>goods_service</artifactId>
      <version>1.0-SNAPSHOT</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <mainClass>com.czxy.goods.MySpringBootStarter</mainClass>
        </configuration>
      </plugin>
    </plugins>
    <resources>
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.xml</include>
        </includes>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
        <includes>
          <include>**/*.*</include>
        </includes>
      </resource>
      <!-- 打包时将jsp文件拷贝到META-INF目录下 -->
      <resource>
        <!-- 指定resources插件处理哪个目录下的资源文件 -->
        <directory>src/main/webapp</directory>
        <!--注意此次必须要放在此目录下才能被访问到 -->
        <targetPath>META-INF/resources</targetPath>
        <includes>
          <include>**/*.*</include>
        </includes>
      </resource>
    </resources>
  </build>

</project>

 

 

 

步骤三: 然后先点击Maven中的clean, 再点击package打包

Linux nexus repository搭建maven私服_linux_02

 

Linux nexus repository搭建maven私服_linux_03

 

 

 

步骤四: 然后target去查看打好的war包

Linux nexus repository搭建maven私服_linux_04

 

 

 

步骤五:: 上传到linux方式一:

 

Linux nexus repository搭建maven私服_jar_05

方式二:使用小插件上传1.在root文件下执行命令下载插件:   这个命令是将安装一个能下载、上传的软件

sudo yum install lrzsz -y 

 

 

2.执行 rz 命令

这是上传命令,执行之后,选择文件,就可以上传了

 

如果文件还没上传,再执行一次rz即可

Linux nexus repository搭建maven私服_java_06

 

 

 

 

 

步骤六:使用命令运行

java -jar 项目.jar

Linux nexus repository搭建maven私服_jar_07

 

 

步骤七:访问

http://192.168.200.130/index.jsp

 

ip可使用命令ip addr 查看,也可直接看顶部

Linux nexus repository搭建maven私服_jar_08

  如果完成以上步骤不能访问页面: 就需要搞搞防火墙了


• 防火墙开启端口号
• firewall-cmd --zone=public --add-port=端口号/tcp --permanent   
•  #重新载入
• firewall-cmd --reload
•  #查看所有打开的端口:
• firewall-cmd --zone=public --list-ports

 

然后重新访问正常是没问题的

 

 

 

看完恭喜你,又知道了一点点!!!