΢

SpringBoot+Maven Ĺʵս

 䣺20180524 14:38:27   zekeTao   text-message.png Ҫ

ƪҪpringBoot+Maven ĹʵսСҲοһ/div>

ƪҪpringBoot+Maven Ĺ£

ĿʹĹ

  1. IntelliJ IDEA
  2. JDK 1.8
  3. apache-maven-3.3.9

Ŀ¼:

  1. Ŀ springboot-multi
  2. ģentitydaoserviceweb

һʹIDEAһpringBootĿ : File -> new -> Project Ŀspringboot-multi

ɾrcĿ¼om.xmlʽpom

<groupId>com.example</groupId> 
<artifactId>springboot-multi</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<!-- ˴pom --> 
<packaging>pom</packaging> 

springboot-multiĿ飬Ŀѡnew -> Module

ɾsrc/main/javasrc/main/javaļֻwebģSpringBootpplication

Ŀpom.xml (ע<modules>ģ

<modelVersion>4.0.0</modelVersion>  
  <groupId>com.example</groupId> 
  <artifactId>springboot-multi</artifactId> 
  <version>0.0.1-SNAPSHOT</version> 
  <!-- ˴pom --> 
  <packaging>pom</packaging> 
 
  <name>springboot-multi</name> 
  <description>Demo project for Spring Boot</description> 
 
  <modules> 
    <module>web</module> 
    <module>service</module> 
    <module>dao</module> 
    <module>entity</module> 
  </modules> 
 
  <parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.5.10.RELEASE</version> 
    <relativePath/> <!-- lookup parent from repository --> 
  </parent> 
 
  <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
    <java.version>1.8</java.version> 
  </properties> 
 
  <dependencies> 
    <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
    </dependency> 
  </dependencies> 
 
  <!--ָʹmaven--> 
  <build> 
    <plugins> 
      <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <version>3.1</version> 
        <configuration> 
          <source>${java.version}</source> 
          <target>${java.version}</target> 
        </configuration> 
      </plugin> 
 
      <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-surefire-plugin</artifactId> 
        <version>2.19.1</version> 
        <configuration> 
          <skipTests>true</skipTests>  <!--Ĭص--> 
        </configuration> 
      </plugin> 
    </plugins> 
  </build> 

webģom.xmlservicedaoentityģ飩 

<modelVersion>4.0.0</modelVersion>  
  <groupId>com.example</groupId> 
  <artifactId>web</artifactId> 
  <version>0.0.1-SNAPSHOT</version> 
  <packaging>jar</packaging> 
 
  <name>web</name> 
  <description>Demo project for Spring Boot</description> 
 
  <parent> 
    <groupId>com.example</groupId> 
    <artifactId>springboot-multi</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <relativePath>../pom.xml</relativePath> 
  </parent> 
 
  <dependencies> 
    <dependency> 
      <groupId>com.example</groupId> 
      <artifactId>service</artifactId> 
      <version>0.0.1-SNAPSHOT</version> 
    </dependency> 
    <dependency> 
      <groupId>com.example</groupId> 
      <artifactId>dao</artifactId> 
      <version>0.0.1-SNAPSHOT</version> 
    </dependency> 
    <dependency> 
      <groupId>com.example</groupId> 
      <artifactId>entity</artifactId> 
      <version>0.0.1-SNAPSHOT</version> 
    </dependency> 
  </dependencies> 
 
  <!--spring bootĻҪָһһ-> 
  <build> 
    <plugins> 
      <plugin> 
        <groupId>org.springframework.boot</groupId> 
        <artifactId>spring-boot-maven-plugin</artifactId> 
        <configuration> 
          <!-- ָain ClassΪȫֵһ--> 
          <mainClass>com.example.WebApplication</mainClass> 
          <layout>ZIP</layout> 
        </configuration> 
        <executions> 
          <execution> 
            <goals> 
              <goal>repackage</goal><!--԰İar-> 
            </goals> 
          </execution> 
        </executions> 
      </plugin> 
    </plugins> 
  </build> 

serviceģom.xml( dao entityģ

<modelVersion>4.0.0</modelVersion> 
 
  <groupId>com.example</groupId> 
  <artifactId>service</artifactId> 
  <version>0.0.1-SNAPSHOT</version> 
  <packaging>jar</packaging> 
 
  <name>service</name> 
  <description>Demo project for Spring Boot</description> 
 
  <parent> 
    <groupId>com.example</groupId> 
    <artifactId>springboot-multi</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <relativePath>../pom.xml</relativePath> 
  </parent> 
 
  <dependencies> 
    <dependency> 
      <groupId>com.example</groupId> 
      <artifactId>dao</artifactId> 
      <version>0.0.1-SNAPSHOT</version> 
    </dependency> 
    <dependency> 
      <groupId>com.example</groupId> 
      <artifactId>entity</artifactId> 
      <version>0.0.1-SNAPSHOT</version> 
    </dependency> 
  </dependencies> 

ˡdaoģom.xml entityģ飩 

<modelVersion>4.0.0</modelVersion> 
 
<groupId>com.example</groupId> 
<artifactId>dao</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>jar</packaging> 
 
<name>dao</name> 
<description>Demo project for Spring Boot</description> 
 
<parent> 
  <groupId>com.example</groupId> 
  <artifactId>springboot-multi</artifactId> 
  <version>0.0.1-SNAPSHOT</version> 
  <relativePath>../pom.xml</relativePath> 
</parent> 
 
<dependencies> 
  <dependency> 
    <groupId>com.example</groupId> 
    <artifactId>entity</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
  </dependency> 
</dependencies> 

šentityģ/p>

<modelVersion>4.0.0</modelVersion> 
 
<groupId>com.example</groupId> 
<artifactId>entity</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>jar</packaging> 
 
<name>entity</name> 
<description>Demo project for Spring Boot</description> 
 
  <parent> 
    <groupId>com.example</groupId> 
    <artifactId>springboot-multi</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <relativePath>../pom.xml</relativePath> 
  </parent> 

ʮpom.xmlҪעľǣ

  1. ĿodulesָǷ
  2. ģ
  3. ģparent

ʮһwebģApplication:

@RestController 
@SpringBootApplication 
public class WebApplication { 
 
  public static void main(String[] args) { 
    SpringApplication.run(WebApplication.class, args); 
  } 
 
  @RequestMapping(value = "/test",method = RequestMethod.GET) 
  public String test(){ 
    return "test success"; 
  } 
} 

ʮִmainĿocalhost:8080/testĿɹ

ʮĿ: mvn clean package ʹ߹ԣ

ʮɹ־

DZϣԴϰϣֽ֧ű֮ҡ

springʹRedisTemplateIJRedis

springʹRedisTemplateIJRedis

ƪҪpringʹRedisTemplateIJRedisIJοԲοһ
2017-05-05
ava볣Ż

ava볣Ż

ƪҪava볣ŻͨķdzϸԴϰ߹IJοѧϰҪһѧϰѧϰ
2019-04-04
play for scala ʵSessionFilter תҳ

play for scala ʵSessionFilter תҳ

ƪҪlay for scala ʵSessionFilter תҳ,ҪѿԲο
2016-11-11
ʹSpringbootOAuth2.0 Serverķʾ

ʹSpringbootOAuth2.0 Serverķʾ

ƪҪSpringbootOAuth2.0 ServerķʾСҲοһ/div> 2018-08-08

/a> - /a> - ϵ - - վ - Ͷ - Ͷ/a>

ghs.png 32031102000137/a>  ICP14036222/a>

©CopyRight 2006-2019 JB51.Net Inc All Rights Reserved. ű֮


此为网页(www.jb51.net)快照,查看来源