class="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 http://www.w3.org/2001/XMLSchema-instance " > <modelVersion>4.0.0</modelVersion> <groupId>serachrate</groupId> <artifactId>serachrate</artifactId> <version>1.0-SNAPSHOT</version> <!--父依赖--> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.2.2.RELEASE</version> </parent> <!--指定编码--> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <pluginManagement> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <!-- 比较常用的打包命令 mvn clean package spring-boot:repackage 只有使用下面的maven命令在cmd窗口启动, 热加载才能生效,如果直接Run运行的Application是 不支持热加载的 mvn clean spring-boot:run --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>1.2.2.RELEASE</version> <dependencies> <!--引入springloaded来实现动态加载--> <dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> <version>1.2.0.RELEASE</version> </dependency> </dependencies> <executions> <execution> <goals> <goal>repackage</goal> </goals> <configuration> <classifier>exec</classifier> </configuration> </execution> </executions> <configuration> <!-- <mainClass>com.dhgate.rate.ApplicationSearch</mainClass> --> <!--指定监听的端口号--> <jvmArguments> -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7777 </jvmArguments> </configuration> </plugin> </plugins> </build> <dependencies> <!--web容器支持--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <!--本例中散仙排除了tomcat,而使用jetty作为容器--> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jetty</artifactId> </dependency> <!-- 安全验证 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> --> <!--Velocity引擎的支持,如果你需要其他的模板引擎,则--> <!--可以直接引入其他的即可--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-velocity</artifactId> </dependency> <!--性能指标和监测--> <!--<dependency>--> <!--<groupId>org.springframework.boot</groupId>--> <!--<artifactId>spring-boot-starter-actuator</artifactId>--> <!--</dependency>--> <!--<dependency>--> <!--<groupId>org.springframework.boot</groupId>--> <!--<artifactId>spring-boot-starter-remote-shell</artifactId>--> <!--</dependency>--> <!--<dependency>--> <!--<groupId>org.springframework.boot</groupId>--> <!--<artifactId>spring-boot-starter-security</artifactId>--> <!--</dependency>--> <!--Guava包的依赖支持--> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>16.0.1</version> </dependency> <!--Gson支持--> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.3.1</version> </dependency> <!--Jsoup支持--> <dependency> <groupId>org.jsoup</groupId> <artifactId>jsoup</artifactId> <version>1.8.1</version> </dependency> <!--solrj的依赖包 --> <dependency> <groupId>org.apache.solr</groupId> <artifactId>solr-solrj</artifactId> <version>4.3.1</version> </dependency> </dependencies> </project>
@RequestMapping("/hello") public String hello(Map<String, Object> model){ List<String> l= Lists.newArrayList(); l.add("哈喽,hadoop"); l.add("哈喽,hbase"); l.add("哈喽,hive"); l.add("哈喽,pig"); l.add("哈喽,zookeeper"); l.add("哈喽,三劫散仙"); //将数据存放map里面,可以直接在velocity页面,使用key访问 model.put("data",l); return "hello"; }
#foreach($s in $data) <h1 style="color: crimson">访问数据:$s</h1> #end
//打包编译该spring boot项目 mvn clean package spring-boot:repackage //以maven方式启动该项目,spring loaded必须使用此启动方法,才能生效 mvn clean spring-boot:run