├── .editorconfig ├── .gitattributes ├── .gitignore ├── .jshintrc ├── .travis.yml ├── LICENSE ├── README.md ├── app ├── index.js └── templates │ ├── Application.java │ ├── application.yml │ ├── build.gradle │ └── pom.xml ├── hateoas ├── index.js └── templates │ ├── Controller.java │ └── Representation.java ├── logo └── Gen-Spring-Logo.jpg ├── package.json ├── rest ├── index.js └── templates │ ├── Controller.java │ └── Representation.java ├── route ├── index.js └── templates │ ├── Controller.java │ └── view.html └── test └── test-load.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | .idea 4 | *.iml -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "esnext": true, 4 | "bitwise": true, 5 | "camelcase": true, 6 | "curly": true, 7 | "eqeqeq": true, 8 | "immed": true, 9 | "indent": 4, 10 | "latedef": true, 11 | "newcap": true, 12 | "noarg": true, 13 | "quotmark": "single", 14 | "regexp": true, 15 | "undef": true, 16 | "unused": true, 17 | "strict": true, 18 | "trailing": true, 19 | "smarttabs": true, 20 | "white": true 21 | } 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '6.5.0' 4 | - '6.9.0' 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Tomas Lin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![logo](logo/Gen-Spring-Logo.jpg?raw=true) 2 | 3 | # generator-spring [![Build Status](https://travis-ci.org/davetownsend/generator-spring.svg?branch=master)](https://travis-ci.org/davetownsend/generator-spring) 4 | 5 | A [Yeoman](http://yeoman.io) generator for scaffolding and bootstrapping [Spring Boot](http://projects.spring.io/spring-boot/) and [Spring Cloud](http://projects.spring.io/spring-cloud/) applications. Provides the same selectable options as [Spring Initializr](http://start.spring.io), but with and interactive CLI interface so your hands can stay where they belong, on the keyboard! 6 | 7 | 8 | ## Getting Started 9 | 10 | **Install Yeoman** 11 | 12 | ``` 13 | $ npm install -g yo 14 | ``` 15 | 16 | **Install generator-spring** 17 | 18 | ``` 19 | $ npm install -g generator-spring 20 | ``` 21 | 22 | **Initiate spring-generator!** 23 | 24 | ``` 25 | $ yo spring 26 | ``` 27 | _The interactive CLI menu will guide the way._ 28 | 29 | 30 | ### Extras (Sub-generators) 31 | Creates a REST endpoint 32 | 33 | ``` 34 | $ yo spring:rest 35 | ``` 36 | 37 | Creates a REST endpoint with HATEOAS support *(has dependency on choosing the hateoas starter option)* 38 | 39 | ``` 40 | $ yo spring:hateoas 41 | ``` 42 | 43 | Creates an initial Thymeleaf view *(has dependency on choosing the Thyemleaf starter option)* 44 | 45 | ``` 46 | $ yo spring:route 47 | ``` 48 | 49 | ## TODO 50 | - Add the new Spring Cloud libs supported with Spring Boot 1.5.x 51 | - Add support for createing a serverless (AWS) project with Spring Cloud Function. 52 | - Add React support. This will essentially scaffold an opinionated react SPA (webpack/es6/material-ui) as the front end. 53 | 54 | ## License 55 | 56 | [MIT License](http://en.wikipedia.org/wiki/MIT_License) 57 | -------------------------------------------------------------------------------- /app/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var util = require('util'); 3 | var path = require('path'); 4 | var yeoman = require('yeoman-generator'); 5 | var chalk = require('chalk'); 6 | var mkdirp = require('mkdirp'); 7 | 8 | var SpringGenerator = module.exports = function SpringGenerator(args, options, config) { 9 | yeoman.generators.Base.apply(this, arguments); 10 | }; 11 | 12 | util.inherits(SpringGenerator, yeoman.generators.Base); 13 | 14 | SpringGenerator.prototype.askFor = function askFor() { 15 | var cb = this.async(); 16 | 17 | console.log(chalk.green('\n.............DD88888888888888888,............\n' + 18 | '...........:888888888888888888888,...........\n' + 19 | '..........+88888888888888888888888+..........\n' + 20 | '.........,8888888888888888888888888..........\n' + 21 | '.........888888888888...888888888888.........\n' + 22 | '.......,88888887..D88...88Z..88888888,.......\n' + 23 | '.......8888888,...888...88D...=8888888.......\n' + 24 | '......D888888,..$8888...88887...8888888......\n' + 25 | '.....Z888888$..I88888...88888:..88888888,....\n' + 26 | '....D8888888...888888...88888D..,88888888....\n' + 27 | '....88888888,..888888..,888888...88888888....\n' + 28 | '....88888888,..8888888$888888D..,88888888....\n' + 29 | '....88888888I..Z8888888888888+..888888888....\n' + 30 | '.....Z8888888...O888888888888..,88888888.....\n' + 31 | '......88888888...,88888888D...,88888888......\n' + 32 | '.......88888888=.....?I+.....I88888888.......\n' + 33 | '.......,88888888D7.........ZD88888888,.......\n' + 34 | '.........888888888888888888888888888.........\n' + 35 | '.........,8888888888888888888888888..........\n' + 36 | '..........+88888888888888888888888+..........\n' + 37 | '...........,888888888888888888888:...........\n' + 38 | '.............DD888888888888888DD.............\n' + 39 | chalk.yellow('\nWelcome to the Spring Boot Generator\n\nLets get started!\n\n'))); 40 | 41 | 42 | var prompts = [ 43 | { 44 | type: 'string', 45 | name: 'bootVersion', 46 | message: 'Enter Spring Boot version:', 47 | default: '1.4.1.RELEASE' 48 | }, { 49 | type: 'string', 50 | name: 'packageName', 51 | message: 'Enter default package name:', 52 | default: 'com.myapp' 53 | }, { 54 | type: 'string', 55 | name: 'baseName', 56 | message: 'Enter base name of app:', 57 | default: 'app' 58 | }, { 59 | type: 'string', 60 | name: 'javaVersion', 61 | message: 'Enter Java version:', 62 | default: '1.8' 63 | }, { 64 | type: 'checkbox', 65 | name: 'packagingType', 66 | message: 'Package type:', 67 | choices: [ 68 | { 69 | name: 'Jar', 70 | value: 'jar' 71 | }, { 72 | name: 'War', 73 | value: 'war' 74 | } 75 | ] 76 | }, { 77 | type: 'checkbox', 78 | name: 'buildTool', 79 | message: 'Select build tool:', 80 | choices: [ 81 | { 82 | name: 'Gradle', 83 | value: 'gradle' 84 | }, { 85 | name: 'Maven', 86 | value: 'maven' 87 | } 88 | ] 89 | }, { 90 | type: 'checkbox', 91 | name: 'coreWeb', 92 | message: 'Select Core/Web Dependencies:', 93 | choices: [ 94 | { 95 | name: 'Web', 96 | value: 'web' 97 | }, { 98 | name: 'Jetty (Tomcat will be uninstalled)', 99 | value: 'jetty' 100 | }, { 101 | name: 'Security', 102 | value: 'security' 103 | }, { 104 | name: 'AOP', 105 | value: 'aop' 106 | }, { 107 | name: 'Websocket', 108 | value: 'websocket' 109 | }, { 110 | name: 'Jersey (JAX-RS)', 111 | value: 'jersey' 112 | }, { 113 | name: 'Rest Repositories', 114 | value: 'rest' 115 | }, { 116 | name: 'Hypermedia (HATEOAS)', 117 | value: 'hateoas' 118 | }, { 119 | name: 'Mobile', 120 | value: 'mobile' 121 | }, { 122 | name: 'REST Docs', 123 | value: 'restdocs' 124 | } 125 | ] 126 | }, { 127 | type: 'checkbox', 128 | name: 'templates', 129 | message: 'Select Template Engine:', 130 | choices: [ 131 | { 132 | name: 'Thymeleaf', 133 | value: 'thymeleaf' 134 | }, { 135 | name: 'Groovy Templates', 136 | value: 'gtemplates' 137 | }, { 138 | name: 'Mustache', 139 | value: 'mustache' 140 | } 141 | ] 142 | }, { 143 | type: 'checkbox', 144 | name: 'data', 145 | message: 'Select Data support:', 146 | choices: [ 147 | { 148 | name: 'Jdbc', 149 | value: 'jdbc' 150 | }, { 151 | name: 'JPA', 152 | value: 'jpa' 153 | }, { 154 | name: 'MongoDB', 155 | value: 'mongodb' 156 | }, { 157 | name: 'Redis', 158 | value: 'redis' 159 | }, { 160 | name: 'Solr', 161 | value: 'solr' 162 | }, { 163 | name: 'Elasticsearch', 164 | value: 'elasticsearch' 165 | } 166 | ] 167 | }, { 168 | type: 'checkbox', 169 | name: 'database', 170 | message: 'Select Database support:', 171 | choices: [ 172 | { 173 | name: 'H2', 174 | value: 'h2' 175 | }, { 176 | name: 'HSQLDB', 177 | value: 'hsqldb' 178 | }, { 179 | name: 'Apache Derby', 180 | value: 'derby' 181 | }, { 182 | name: 'MySQL', 183 | value: 'mysql' 184 | }, { 185 | name: 'PostgreSQL', 186 | value: 'postgresql' 187 | } 188 | ] 189 | }, { 190 | type: 'checkbox', 191 | name: 'cloud', 192 | message: 'Select Spring Cloud support:', 193 | choices: [ 194 | { 195 | name: 'Cloud Connectors', 196 | value: 'connectors' 197 | }, { 198 | name: 'Cloud Bootstrap', 199 | value: 'bootstrap' 200 | }, { 201 | name: 'Config Client', 202 | value: 'configClient' 203 | }, { 204 | name: 'Config Server', 205 | value: 'configServer' 206 | }, { 207 | name: 'Eureka', 208 | value: 'eureka' 209 | }, { 210 | name: 'Eureka Server', 211 | value: 'eurekaServer' 212 | }, { 213 | name: 'Feign', 214 | value: 'feign' 215 | }, { 216 | name: 'Hystrix', 217 | value: 'hystrix' 218 | }, { 219 | name: 'Hystrix Dashboard', 220 | value: 'hystrixDashboard' 221 | }, { 222 | name: 'OAuth2', 223 | value: 'oauth2' 224 | }, { 225 | name: 'Ribbon', 226 | value: 'ribbon' 227 | }, { 228 | name: 'Turbine', 229 | value: 'turbine' 230 | }, { 231 | name: 'Turbine AMQP', 232 | value: 'turbineAmqp' 233 | }, { 234 | name: 'Zuul', 235 | value: 'zuul' 236 | }, { 237 | name: 'AWS', 238 | value: 'aws' 239 | }, { 240 | name: 'AWS JDBC', 241 | value: 'awsJdbc' 242 | }, { 243 | name: 'AWS Messaging', 244 | value: 'awsMessaging' 245 | }, { 246 | name: 'Cloud Bus AMQP', 247 | value: 'cloudBus' 248 | }, { 249 | name: 'Cloud Security', 250 | value: 'cloudSecurity' 251 | } 252 | ] 253 | }, { 254 | type: 'checkbox', 255 | name: 'io', 256 | message: 'Select I/O support:', 257 | choices: [ 258 | { 259 | name: 'Batch', 260 | value: 'batch' 261 | }, { 262 | name: 'Integration', 263 | value: 'integration' 264 | }, { 265 | name: 'JMS (HornetQ)', 266 | value: 'jms' 267 | }, { 268 | name: 'AMQP', 269 | value: 'amqp' 270 | }, { 271 | name: 'Mail', 272 | value: 'mail' 273 | } 274 | ] 275 | }, { 276 | type: 'checkbox', 277 | name: 'social', 278 | message: 'Select Social APIs:', 279 | choices: [ 280 | { 281 | name: 'Facebook', 282 | value: 'facebook' 283 | }, { 284 | name: 'LinkedIn', 285 | value: 'linkedin' 286 | }, { 287 | name: 'Twitter', 288 | value: 'twitter' 289 | } 290 | ] 291 | }, { 292 | type: 'checkbox', 293 | name: 'ops', 294 | message: 'Select OPS tools:', 295 | choices: [ 296 | { 297 | name: 'Actuator', 298 | value: 'actuator' 299 | }, { 300 | name: 'Remote Shell', 301 | value: 'remoteshell' 302 | } 303 | ] 304 | }, { 305 | type: 'confirm', 306 | name: 'useSpock', 307 | message: 'Use Spock?', 308 | default: true 309 | }, { 310 | type: 'string', 311 | name: 'groovyVersion', 312 | message: 'Enter Groovy version:', 313 | default: '2.4.4' 314 | } 315 | ]; 316 | 317 | this.prompt(prompts, function(props) { 318 | this.bootVersion = props.bootVersion; 319 | this.packageName = props.packageName; 320 | this.baseName = props.baseName; 321 | this.javaVersion = props.javaVersion; 322 | this.packagingType = props.packagingType; 323 | this.coreWeb = props.coreWeb; 324 | this.templates = props.templates; 325 | this.data = props.data; 326 | this.database = props.database; 327 | this.cloud = props.cloud; 328 | this.io = props.io; 329 | this.social = props.social; 330 | this.ops = props.ops; 331 | this.useSpock = props.useSpock; 332 | this.groovyVersion = props.groovyVersion; 333 | this.buildTool = props.buildTool; 334 | 335 | // Packaging Type 336 | var hasPackagingType = function(packagingTypeStarter) { 337 | return props.packagingType.indexOf(packagingTypeStarter) !== -1; 338 | }; 339 | this.jar = hasPackagingType('jar'); 340 | this.war = hasPackagingType('war'); 341 | 342 | // Core/Web 343 | var hasCoreWeb = function(coreWebStarter) { 344 | return props.coreWeb.indexOf(coreWebStarter) !== -1; 345 | }; 346 | this.web = hasCoreWeb('web'); 347 | this.jetty = hasCoreWeb('jetty'); 348 | this.security = hasCoreWeb('security'); 349 | this.aop = hasCoreWeb('aop'); 350 | this.websocket = hasCoreWeb('websocket'); 351 | this.jersey = hasCoreWeb('jersey'); 352 | this.rest = hasCoreWeb('rest'); 353 | this.hateoas = hasCoreWeb('hateoas'); 354 | this.mobile = hasCoreWeb('mobile'); 355 | this.restdocs = hasCoreWeb('restdocs'); 356 | 357 | // Template Engines 358 | var hasTemplate = function(templateStarter) { 359 | return props.templates.indexOf(templateStarter) !== -1; 360 | }; 361 | this.thymeleaf = hasTemplate('thymeleaf'); 362 | this.gtemplates = hasTemplate('gtemplates'); 363 | this.mustache = hasTemplate('mustache'); 364 | 365 | // Spring Data 366 | var hasData = function(dataStarter) { 367 | return props.data.indexOf(dataStarter) !== -1; 368 | }; 369 | this.jdbc = hasData('jdbc'); 370 | this.jpa = hasData('jpa'); 371 | this.mongodb = hasData('mongodb'); 372 | this.redis = hasData('redis'); 373 | this.gemfire = hasData('gemfire'); 374 | this.solr = hasData('solr'); 375 | this.elasticsearch = hasData('elasticsearch'); 376 | 377 | // Databases 378 | var hasDatabase = function(databaseStarter) { 379 | return props.database.indexOf(databaseStarter) !== -1; 380 | }; 381 | this.h2 = hasDatabase('h2'); 382 | this.hsqldb = hasDatabase('hsqldb'); 383 | this.derby = hasDatabase('derby'); 384 | this.mysql = hasDatabase('mysql'); 385 | this.postgresql = hasDatabase('postgresql'); 386 | 387 | // Spring Cloud 388 | prompts.push({ 389 | type: 'string', 390 | name: 'usesCloud', 391 | message: 'usesCloud', 392 | default: false 393 | }); 394 | var hasCloud = function(cloudStarter) { 395 | return props.cloud.indexOf(cloudStarter) !== -1; 396 | }; 397 | this.connectors = hasCloud('connectors'); 398 | this.bootstrap = hasCloud('bootstrap'); 399 | this.configClient = hasCloud('configClient'); 400 | this.configServer = hasCloud('configServer'); 401 | this.eureka = hasCloud('eureka'); 402 | this.eurekaServer = hasCloud('eurekaServer'); 403 | this.feign = hasCloud('feign'); 404 | this.hystrix = hasCloud('hystrix'); 405 | this.hystrixDashboard = hasCloud('hystrixDashboard'); 406 | this.oauth2 = hasCloud('oauth2'); 407 | this.ribbon = hasCloud('ribbon'); 408 | this.turbine = hasCloud('turbine'); 409 | this.turbineAmqp = hasCloud('turbineAmqp'); 410 | this.zuul = hasCloud('zuul'); 411 | this.aws = hasCloud('aws'); 412 | this.awsJdbc = hasCloud('awsJdbc'); 413 | this.awsMessaging = hasCloud('awsMessaging'); 414 | this.cloudBus = hasCloud('cloudBus'); 415 | this.cloudSecurity = hasCloud('cloudSecurity'); 416 | this.usesCloud = props.cloud.length > 0; 417 | 418 | // I/O 419 | var hasIO = function(ioStarter) { 420 | return props.io.indexOf(ioStarter) !== -1; 421 | }; 422 | this.batch = hasIO('batch'); 423 | this.integration = hasIO('integration'); 424 | this.jms = hasIO('jms'); 425 | this.amqp = hasIO('amqp'); 426 | this.mail = hasIO('mail'); 427 | 428 | // Social 429 | var hasSocial = function(socialStarter) { 430 | return props.social.indexOf(socialStarter) !== -1; 431 | }; 432 | this.facebook = hasSocial('facebook'); 433 | this.linkedin = hasSocial('linkedin'); 434 | this.twitter = hasSocial('twitter'); 435 | 436 | // OPS 437 | var hasOps = function(opsStarter) { 438 | return props.ops.indexOf(opsStarter) !== -1; 439 | }; 440 | this.actuator = hasOps('actuator'); 441 | this.remoteshell = hasOps('remoteshell'); 442 | 443 | cb(); 444 | }.bind(this)); 445 | }; 446 | 447 | SpringGenerator.prototype.app = function app() { 448 | var packageFolder = this.packageName.replace(/\./g, '/'); 449 | var srcDir = 'src/main/java/' + packageFolder; 450 | var resourceDir = 'src/main/resources'; 451 | mkdirp(srcDir); 452 | 453 | if ('gradle' === this.buildTool[0]) { 454 | this.template('build.gradle', 'build.gradle'); 455 | } 456 | if ('maven' === this.buildTool[0]) { 457 | this.template('pom.xml', 'pom.xml'); 458 | } 459 | 460 | this.template('Application.java', srcDir + '/Application.java'); 461 | 462 | if (this.useSpock) { 463 | var testDir = 'src/test/groovy/' + packageFolder; 464 | mkdirp(testDir); 465 | } 466 | if (this.web || this.thymeleaf || this.gtemplates || this.mustache) { 467 | mkdirp('src/main/resources'); 468 | mkdirp('src/main/resources/static'); 469 | mkdirp('src/main/resources/templates'); 470 | this.template('application.yml', resourceDir + '/application.yml'); 471 | } 472 | this.config.set('packageName', this.packageName); 473 | this.config.set('packageFolder', packageFolder); 474 | }; 475 | 476 | SpringGenerator.prototype.projectfiles = function projectfiles() {}; 477 | -------------------------------------------------------------------------------- /app/templates/Application.java: -------------------------------------------------------------------------------- 1 | package <%=packageName%>; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /app/templates/application.yml: -------------------------------------------------------------------------------- 1 | info: 2 | version: 0.0.1 3 | 4 | spring: 5 | application: 6 | name: <%= baseName %> 7 | -------------------------------------------------------------------------------- /app/templates/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | maven { url "https://repo.spring.io/snapshot" } 5 | maven { url "https://repo.spring.io/milestone" } 6 | } 7 | dependencies { 8 | classpath("org.springframework.boot:spring-boot-gradle-plugin:<%= bootVersion %>") 9 | } 10 | } 11 | <% if (war) { %>apply plugin: 'war'<% } %> 12 | apply plugin: 'java' 13 | apply plugin: 'eclipse' 14 | apply plugin: 'idea' 15 | apply plugin: 'spring-boot' 16 | 17 | sourceCompatibility = '<%= javaVersion %>' 18 | targetCompatibility = '<%= javaVersion %>' 19 | 20 | repositories { 21 | mavenCentral() 22 | maven { url "https://repo.spring.io/snapshot" } 23 | maven { url "https://repo.spring.io/milestone" } 24 | } 25 | 26 | dependencies { 27 | <% if (web) { %>compile("org.springframework.boot:spring-boot-starter-web")<% if (jetty) { %> { 28 | exclude module: "spring-boot-starter-tomcat" 29 | } 30 | compile("org.springframework.boot:spring-boot-starter-jetty")<% } %> 31 | <% } %> 32 | <% if (security) { %>compile("org.springframework.boot:spring-boot-starter-security")<% } %> 33 | <% if (aop) { %>compile("org.springframework.boot:spring-boot-starter-aop")<% } %> 34 | <% if (websocket) { %>compile("org.springframework.boot:spring-boot-starter-websocket")<% } %> 35 | <% if (jersey) { %>compile("org.springframework.boot:spring-boot-starter-jersey")<% } %> 36 | <% if (rest) { %>compile("org.springframework.boot:spring-boot-starter-data-rest")<% } %> 37 | <% if (hateoas) { %>compile("org.springframework.boot:spring-boot-starter-hateoas")<% } %> 38 | <% if (mobile) { %>compile("org.springframework.boot:spring-boot-starter-mobile")<% } %> 39 | <% if (restdocs) { %>compile("org.springframework.restdocs:spring-restdocs-mockmvc:1.0.0.RELEASE")<% } %> 40 | 41 | <% if (thymeleaf) { %>compile("org.springframework.boot:spring-boot-starter-thymeleaf")<% } %> 42 | <% if (gtemplates) { %>compile("org.springframework.boot:spring-boot-starter-groovy-templates")<% } %> 43 | <% if (mustache) { %>compile("org.springframework.boot:spring-boot-starter-mustache")<% } %> 44 | 45 | <% if (jdbc) { %>compile("org.springframework.boot:spring-boot-starter-jdbc")<% } %> 46 | <% if (jpa) { %>compile("org.springframework.boot:spring-boot-starter-data-jpa")<% } %> 47 | <% if (mongodb) { %>compile("org.springframework.boot:spring-boot-starter-data-mongodb")<% } %> 48 | <% if (redis) { %>compile("org.springframework.boot:spring-boot-starter-data-redis")<% } %> 49 | <% if (solr) { %>compile("org.springframework.boot:spring-boot-starter-data-solr")<% } %> 50 | <% if (elasticsearch) { %>compile("org.springframework.boot:spring-boot-starter-data-elasticsearch")<% } %> 51 | 52 | <% if (connectors) { %>compile("org.springframework.boot:spring-boot-starter-cloud-connectors")<% } %> 53 | <% if (bootstrap) { %>compile("org.springframework.cloud:spring-cloud-starter")<% } %> 54 | <% if (configClient) { %>compile("org.springframework.cloud:spring-cloud-starter-config")<% } %> 55 | <% if (configServer) { %>compile("org.springframework.cloud:spring-cloud-config-server")<% } %> 56 | <% if (eureka) { %>compile("org.springframework.cloud:spring-cloud-starter-eureka")<% } %> 57 | <% if (eurekaServer) { %>compile("org.springframework.cloud:spring-cloud-starter-eureka-server")<% } %> 58 | <% if (feign) { %>compile("org.springframework.cloud:spring-cloud-starter-feign")<% } %> 59 | <% if (hystrix) { %>compile("org.springframework.cloud:spring-cloud-starter-hystrix")<% } %> 60 | <% if (hystrixDashboard) { %>compile("org.springframework.cloud:spring-cloud-starter-hystrix-dashboard")<% } %> 61 | <% if (oauth2) { %>compile("org.springframework.cloud:spring-cloud-starter-oauth2")<% } %> 62 | <% if (ribbon) { %>compile("org.springframework.cloud:spring-cloud-starter-ribbon")<% } %> 63 | <% if (turbine) { %>compile("org.springframework.cloud:spring-cloud-starter-turbine")<% } %> 64 | <% if (turbineAmqp) { %>compile("org.springframework.cloud:spring-cloud-starter-turbine-amqp")<% } %> 65 | <% if (zuul) { %>compile("org.springframework.cloud:spring-cloud-starter-zuul")<% } %> 66 | <% if (aws) { %>compile("org.springframework.cloud:spring-cloud-starter-aws")<% } %> 67 | <% if (awsJdbc) { %>compile("org.springframework.cloud:spring-cloud-starter-aws-jdbc")<% } %> 68 | <% if (awsMessaging) { %>compile("org.springframework.cloud:spring-cloud-starter-aws-messaging")<% } %> 69 | <% if (cloudBus) { %>compile("org.springframework.cloud:spring-cloud-starter-bus-amqp")<% } %> 70 | <% if (cloudSecurity) { %>compile("org.springframework.cloud:spring-cloud-starter-security")<% } %> 71 | 72 | <% if (batch) { %>compile("org.springframework.boot:spring-boot-starter-batch")<% } %> 73 | <% if (integration) { %>compile("org.springframework.boot:spring-boot-starter-integration")<% } %> 74 | <% if (jms) { %>compile("org.springframework.boot:spring-boot-starter-hornetq")<% } %> 75 | <% if (amqp) { %>compile("org.springframework.boot:spring-boot-starter-amqp")<% } %> 76 | <% if (mail) { %>compile("org.springframework.boot:spring-boot-starter-mail")<% } %> 77 | 78 | <% if (facebook) { %>compile("org.springframework.boot:spring-boot-starter-social-facebook")<% } %> 79 | <% if (linkedin) { %>compile("org.springframework.boot:spring-boot-starter-social-linkedin")<% } %> 80 | <% if (twitter) { %>compile("org.springframework.boot:spring-boot-starter-social-twitter")<% } %> 81 | 82 | <% if (actuator) { %>compile("org.springframework.boot:spring-boot-starter-actuator")<% } %> 83 | <% if (remoteshell) { %>compile("org.springframework.boot:spring-boot-starter-remote-shell")<% } %> 84 | compile("org.codehaus.groovy:groovy:<%= groovyVersion %>") 85 | 86 | <% if (h2) { %>runtime("com.h2database:h2")<% } %> 87 | <% if (hsqldb) { %>runtime("org.hsqldb:hsqldb")<% } %> 88 | <% if (derby) { %>runtime("org.apache.derby:derby")<% } %> 89 | <% if (mysql) { %>runtime("mysql:mysql-connector-java")<% } %> 90 | <% if (postgresql) { %>runtime("org.postgresql:postgresql:9.4-1201-jdbc41")<% } %> 91 | 92 | <% if (useSpock) { %> 93 | testCompile("org.spockframework:spock-spring") 94 | testCompile("org.spockframework:spock-core:1.0-groovy-2.4") 95 | <% } %> 96 | <% if (web) { %>testCompile("org.springframework.boot:spring-boot-starter-test")<% } %> 97 | } 98 | 99 | <% if (usesCloud) { %> 100 | dependencyManagement { 101 | imports { 102 | mavenBom("org.springframework.cloud:spring-cloud-starter-parent:Angel.SR3") 103 | } 104 | } 105 | <% } %> 106 | <% if (jar) { %> 107 | jar { 108 | baseName = '<%= baseName %>' 109 | }<% } %> 110 | <% if (war) { %> 111 | war { 112 | baseName = '<%= baseName %>' 113 | }<% } %> 114 | 115 | task (type: Wrapper) { 116 | gradleVersion = '2.3' 117 | } 118 | -------------------------------------------------------------------------------- /app/templates/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | <%=packageName%> 7 | <%= baseName %> 8 | 0.0.1-SNAPSHOT 9 | <% if (jar) { %>jar<% } %><% if (war) { %>war<% } %> 10 | <%= baseName %> 11 | generator-spring project 12 | 13 | 14 | org.springframework.boot 15 | spring-boot-starter-parent 16 | <%= bootVersion %> 17 | 18 | 19 | 20 | 21 | UTF-8 22 | <%= javaVersion %> 23 | 24 | 25 | <% if (actuator) { %> 26 | 27 | org.springframework.boot 28 | spring-boot-starter-actuator 29 | <% } %><% if (amqp) { %> 30 | 31 | org.springframework.boot 32 | spring-boot-starter-amqp 33 | <% } %><% if (aop) { %> 34 | 35 | org.springframework.boot 36 | spring-boot-starter-aop 37 | <% } %><% if (batch) { %> 38 | 39 | org.springframework.boot 40 | spring-boot-starter-batch 41 | <% } %><% if (aws) { %> 42 | 43 | org.springframework.cloud 44 | spring-cloud-starter-aws 45 | <% } %><% if (awsJdbc) { %> 46 | 47 | org.springframework.cloud 48 | spring-cloud-starter-aws-jdbc 49 | <% } %><% if (awsMessaging) { %> 50 | 51 | org.springframework.cloud 52 | spring-cloud-starter-aws-messaging 53 | <% } %><% if (cloudBus) { %> 54 | 55 | org.springframework.cloud 56 | spring-cloud-starter-bus-amqp 57 | <% } %><% if (configClient) { %> 58 | 59 | org.springframework.cloud 60 | spring-cloud-starter-config 61 | <% } %><% if (configServer) { %> 62 | 63 | org.springframework.cloud 64 | spring-cloud-config-server 65 | <% } %><% if (connectors) { %> 66 | 67 | org.springframework.boot 68 | spring-boot-starter-cloud-connectors 69 | <% } %><% if (eureka) { %> 70 | 71 | org.springframework.cloud 72 | spring-cloud-starter-eureka 73 | <% } %><% if (eurekaServer) { %> 74 | 75 | org.springframework.cloud 76 | spring-cloud-starter-eureka-server 77 | <% } %><% if (feign) { %> 78 | 79 | org.springframework.cloud 80 | spring-cloud-starter-feign 81 | <% } %><% if (hystrix) { %> 82 | 83 | org.springframework.cloud 84 | spring-cloud-starter-hystrix 85 | <% } %><% if (hystrixDashboard) { %> 86 | 87 | org.springframework.cloud 88 | spring-cloud-starter-hystrix-dashboard 89 | <% } %><% if (oauth2) { %> 90 | 91 | org.springframework.cloud 92 | spring-cloud-starter-oauth2 93 | <% } %><% if (ribbon) { %> 94 | 95 | org.springframework.cloud 96 | spring-cloud-starter-ribbon 97 | <% } %><% if (cloudSecurity) { %> 98 | 99 | org.springframework.cloud 100 | spring-cloud-starter-security 101 | <% } %><% if (bootstrap) { %> 102 | 103 | org.springframework.cloud 104 | spring-cloud-starter 105 | <% } %><% if (turbine) { %> 106 | 107 | org.springframework.cloud 108 | spring-cloud-starter-turbine 109 | <% } %><% if (turbineAmqp) { %> 110 | 111 | org.springframework.cloud 112 | spring-cloud-starter-turbine-amqp 113 | <% } %><% if (zuul) { %> 114 | 115 | org.springframework.cloud 116 | spring-cloud-starter-zuul 117 | <% } %><% if (elasticsearch) { %> 118 | 119 | org.springframework.boot 120 | spring-boot-starter-data-elasticsearch 121 | <% } %><% if (jpa) { %> 122 | 123 | org.springframework.boot 124 | spring-boot-starter-data-jpa 125 | <% } %><% if (awsMessaging) { %> 126 | 127 | org.springframework.boot 128 | spring-boot-starter-data-mongodb 129 | <% } %><% if (rest) { %> 130 | 131 | org.springframework.boot 132 | spring-boot-starter-data-rest 133 | <% } %><% if (solr) { %> 134 | 135 | org.springframework.boot 136 | spring-boot-starter-data-solr 137 | <% } %><% if (gtemplates) { %> 138 | 139 | org.springframework.boot 140 | spring-boot-starter-groovy-templates 141 | <% } %><% if (hateoas) { %> 142 | 143 | org.springframework.boot 144 | spring-boot-starter-hateoas 145 | <% } %><% if (jms) { %> 146 | 147 | org.springframework.boot 148 | spring-boot-starter-hornetq 149 | <% } %><% if (integration) { %> 150 | 151 | org.springframework.boot 152 | spring-boot-starter-integration 153 | <% } %><% if (jdbc) { %> 154 | 155 | org.springframework.boot 156 | spring-boot-starter-jdbc 157 | <% } %><% if (jersey) { %> 158 | 159 | org.springframework.boot 160 | spring-boot-starter-jersey 161 | <% } %><% if (mail) { %> 162 | 163 | org.springframework.boot 164 | spring-boot-starter-mail 165 | <% } %><% if (mobile) { %> 166 | 167 | org.springframework.boot 168 | spring-boot-starter-mobile 169 | <% } %><% if (mustache) { %> 170 | 171 | org.springframework.boot 172 | spring-boot-starter-mustache 173 | <% } %><% if (redis) { %> 174 | 175 | org.springframework.boot 176 | spring-boot-starter-data-redis 177 | <% } %><% if (remoteshell) { %> 178 | 179 | org.springframework.boot 180 | spring-boot-starter-remote-shell 181 | <% } %><% if (security) { %> 182 | 183 | org.springframework.boot 184 | spring-boot-starter-security 185 | <% } %><% if (facebook) { %> 186 | 187 | org.springframework.boot 188 | spring-boot-starter-social-facebook 189 | <% } %><% if (awsMessaging) { %> 190 | 191 | org.springframework.boot 192 | spring-boot-starter-social-linkedin 193 | <% } %><% if (linkedin) { %> 194 | 195 | org.springframework.boot 196 | spring-boot-starter-social-twitter 197 | <% } %><% if (twitter) { %> 198 | 199 | org.springframework.boot 200 | spring-boot-starter-thymeleaf 201 | <% } %><% if (web) { %> 202 | 203 | org.springframework.boot 204 | spring-boot-starter-web 205 | <% } %><% if (jetty) { %> 206 | 207 | org.springframework.boot 208 | spring-boot-starter-web 209 | 210 | 211 | org.springframework.boot 212 | spring-boot-starter-tomcat 213 | 214 | 215 | 216 | 217 | org.springframework.boot 218 | spring-boot-starter-jetty 219 | <% } %><% if (websocket) { %> 220 | 221 | org.springframework.boot 222 | spring-boot-starter-websocket 223 | <% } %><% if (derby) { %> 224 | 225 | org.apache.derby 226 | derby 227 | runtime 228 | <% } %><% if (h2) { %> 229 | 230 | com.h2database 231 | h2 232 | runtime 233 | <% } %><% if (hsqldb) { %> 234 | 235 | org.hsqldb 236 | hsqldb 237 | runtime 238 | <% } %><% if (mysql) { %> 239 | 240 | mysql 241 | mysql-connector-java 242 | runtime 243 | <% } %><% if (postgresql) { %> 244 | 245 | org.postgresql 246 | postgresql 247 | 9.4-1201-jdbc41 248 | runtime 249 | <% } %><% if (web) { %> 250 | 251 | org.springframework.boot 252 | spring-boot-starter-test 253 | test 254 | <% } %><% if (restdocs) { %> 255 | 256 | org.springframework.restdocs 257 | spring-restdocs-mockmvc 258 | 1.0.0.RELEASE 259 | test 260 | <% } %><% if (useSpock) { %> 261 | 262 | org.spockframework 263 | spock-spring 264 | test 265 | <% } %> 266 | 267 | 268 | <% if (usesCloud) { %> 269 | 270 | 271 | 272 | org.springframework.cloud 273 | spring-cloud-starter-parent 274 | Angel.SR3 275 | pom 276 | import 277 | 278 | 279 | 280 | <% } %> 281 | 282 | 283 | 284 | 285 | org.springframework.boot 286 | spring-boot-maven-plugin 287 | 288 | 289 | 290 | 291 | -------------------------------------------------------------------------------- /hateoas/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var util = require('util'); 3 | var yeoman = require('yeoman-generator'); 4 | var mkdirp = require('mkdirp'); 5 | 6 | var HateoasGenerator = module.exports = function HateoasGenerator(args, options, config) { 7 | yeoman.generators.Base.apply(this, arguments); 8 | }; 9 | 10 | util.inherits(HateoasGenerator, yeoman.generators.Base); 11 | 12 | HateoasGenerator.prototype.askFor = function askFor() { 13 | var cb = this.async(); 14 | 15 | var prompts = [ 16 | { 17 | type: 'string', 18 | name: 'packageName', 19 | message: '(1/4) Package name:', 20 | default: this.config.get('packageName') 21 | }, 22 | { 23 | type: 'string', 24 | name: 'representation', 25 | message: '(2/4) Name for your representation class:', 26 | default: 'MyThing' 27 | }, 28 | { 29 | type: 'string', 30 | name: 'controllerName', 31 | message: '(3/4) Name for your controller:', 32 | default: 'MyController' 33 | }, 34 | { 35 | type: 'string', 36 | name: 'controllerPath', 37 | message: '(4/4) Path to Controller:', 38 | default: '/hello-world' 39 | } 40 | ] 41 | 42 | this.prompt(prompts, function (props) { 43 | this.packageName = props.packageName; 44 | this.representation = props.representation; 45 | this.controllerName = props.controllerName; 46 | this.controllerPath = props.controllerPath; 47 | cb(); 48 | }.bind(this)); 49 | 50 | }; 51 | 52 | HateoasGenerator.prototype.files = function app() { 53 | var packageFolder = this.packageName.replace(/\./g, '/'); 54 | var controllersDir = 'src/main/java/' + packageFolder + '/controller'; 55 | var domainsDir = 'src/main/java/' + packageFolder + '/domain'; 56 | 57 | mkdirp(controllersDir); 58 | mkdirp(domainsDir); 59 | 60 | this.template('Controller.java', controllersDir + '/' + this.controllerName + '.java'); 61 | this.template('Representation.java', domainsDir + '/' + this.representation + '.java'); 62 | 63 | this.config.set('packageName', this.packageName); 64 | }; 65 | -------------------------------------------------------------------------------- /hateoas/templates/Controller.java: -------------------------------------------------------------------------------- 1 | package <%= packageName %>.controller; 2 | 3 | import static org.springframework.hateoas.mvc.ControllerLinkBuilder.*; 4 | 5 | import org.springframework.http.HttpEntity; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.ResponseBody; 12 | 13 | import <%= packageName %>.domain.<%= representation %>; 14 | 15 | 16 | @Controller 17 | public class <%= controllerName %> { 18 | 19 | @RequestMapping("<%= controllerPath %>") 20 | @ResponseBody 21 | public HttpEntity<<%= representation %>> process(@RequestParam(value = "content", required = false, defaultValue = "content") String content) { 22 | 23 | <%= representation %> entity = new <%= representation %>( content ); 24 | entity.add(linkTo(methodOn(<%= controllerName %>.class).process(content)).withSelfRel()); 25 | 26 | return new ResponseEntity<<%= representation %>>(entity, HttpStatus.OK); 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /hateoas/templates/Representation.java: -------------------------------------------------------------------------------- 1 | package <%= packageName%>.domain; 2 | 3 | import org.springframework.hateoas.ResourceSupport; 4 | 5 | public class <%=representation%> extends ResourceSupport { 6 | 7 | private final String content; 8 | 9 | public <%=representation%>(String content) { 10 | this.content = content; 11 | } 12 | 13 | public String getContent() { 14 | return content; 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /logo/Gen-Spring-Logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davetownsend/generator-spring/bedca95440ac455f88495ef25177d9ae0cf87be5/logo/Gen-Spring-Logo.jpg -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-spring", 3 | "version": "1.0.0", 4 | "description": "A Yeoman Generator for Spring Boot and Spring Cloud", 5 | "keywords": [ 6 | "yeoman-generator" 7 | ], 8 | "homepage": "https://github.com/davetownsend/generator-spring", 9 | "bugs": "https://github.com/davetownsend/generator-spring/issues", 10 | "author": { 11 | "name": "Dave Townsend", 12 | "email": "dave.townsend01@gmail.com", 13 | "url": "https://github.com/davetownsend" 14 | }, 15 | "main": "app/index.js", 16 | "repository": { 17 | "type": "git", 18 | "url": "git://github.com/davetownsend/generator-spring.git" 19 | }, 20 | "scripts": { 21 | "test": "mocha" 22 | }, 23 | "dependencies": { 24 | "yeoman-generator": "~0.21.0", 25 | "chalk": "~1.1.3" 26 | }, 27 | "devDependencies": { 28 | "mocha": "~3.1.2" 29 | }, 30 | "licenses": [ 31 | { 32 | "type": "MIT" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /rest/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var util = require('util'); 3 | var yeoman = require('yeoman-generator'); 4 | var mkdirp = require('mkdirp'); 5 | 6 | var RestGenerator = module.exports = function RestGenerator(args, options, config) { 7 | yeoman.generators.Base.apply(this, arguments); 8 | }; 9 | 10 | util.inherits(RestGenerator, yeoman.generators.Base); 11 | 12 | RestGenerator.prototype.askFor = function askFor() { 13 | var cb = this.async(); 14 | 15 | var prompts = [ 16 | { 17 | type: 'string', 18 | name: 'packageName', 19 | message: '(1/4) Package name:', 20 | default: this.config.get('packageName') 21 | }, 22 | { 23 | type: 'string', 24 | name: 'representation', 25 | message: '(2/4) Name for your representation class:', 26 | default: 'MyThing' 27 | }, 28 | { 29 | type: 'string', 30 | name: 'controllerName', 31 | message: '(3/4) Name for your controller:', 32 | default: 'MyController' 33 | }, 34 | { 35 | type: 'string', 36 | name: 'controllerPath', 37 | message: '(4/4) Path to Controller:', 38 | default: '/hello-world' 39 | } 40 | ] 41 | 42 | this.prompt(prompts, function (props) { 43 | this.packageName = props.packageName; 44 | this.representation = props.representation; 45 | this.controllerName = props.controllerName; 46 | this.controllerPath = props.controllerPath; 47 | cb(); 48 | }.bind(this)); 49 | 50 | }; 51 | 52 | RestGenerator.prototype.files = function app() { 53 | var packageFolder = this.packageName.replace(/\./g, '/'); 54 | var controllersDir = 'src/main/java/' + packageFolder + '/controller'; 55 | var domainsDir = 'src/main/java/' + packageFolder + '/domain'; 56 | 57 | mkdirp(controllersDir); 58 | mkdirp(domainsDir); 59 | 60 | this.template('Controller.java', controllersDir + '/' + this.controllerName + '.java'); 61 | this.template('Representation.java', domainsDir + '/' + this.representation + '.java'); 62 | 63 | this.config.set('packageName', this.packageName); 64 | }; 65 | -------------------------------------------------------------------------------- /rest/templates/Controller.java: -------------------------------------------------------------------------------- 1 | package <%= packageName %>.controller; 2 | 3 | import java.util.concurrent.atomic.AtomicLong; 4 | 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import org.springframework.web.bind.annotation.ResponseBody; 10 | import <%= packageName %>.domain.<%= representation %>; 11 | 12 | 13 | @Controller 14 | @RequestMapping("<%= controllerPath %>") 15 | public class <%= controllerName %> { 16 | 17 | private final AtomicLong counter = new AtomicLong(); 18 | 19 | @RequestMapping(method = RequestMethod.GET) 20 | public 21 | @ResponseBody 22 | <%= representation %> process(@RequestParam(value = "content", required = false, defaultValue = "content") String content) { 23 | return new <%= representation %>(counter.incrementAndGet(), content ); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /rest/templates/Representation.java: -------------------------------------------------------------------------------- 1 | package <%= packageName%>.domain; 2 | 3 | public class <%=representation%> { 4 | 5 | private final long id; 6 | private final String content; 7 | 8 | public <%=representation%>(long id, String content) { 9 | this.id = id; 10 | this.content = content; 11 | } 12 | 13 | public long getId() { 14 | return id; 15 | } 16 | 17 | public String getContent() { 18 | return content; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /route/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var util = require('util'); 3 | var yeoman = require('yeoman-generator'); 4 | var mkdirp = require('mkdirp'); 5 | 6 | var RestGenerator = module.exports = function RestGenerator(args, options, config) { 7 | yeoman.generators.Base.apply(this, arguments); 8 | }; 9 | 10 | util.inherits(RestGenerator, yeoman.generators.Base); 11 | 12 | RestGenerator.prototype.askFor = function askFor() { 13 | var cb = this.async(); 14 | 15 | var prompts = [ 16 | { 17 | type: 'string', 18 | name: 'packageName', 19 | message: '(1/4) Package name:', 20 | default: this.config.get('packageName') 21 | }, 22 | { 23 | type: 'string', 24 | name: 'viewName', 25 | message: '(2/4) Name for your view:', 26 | default: 'page' 27 | }, 28 | { 29 | type: 'string', 30 | name: 'controllerName', 31 | message: '(3/4) Name for your controller:', 32 | default: 'MyController' 33 | }, 34 | { 35 | type: 'string', 36 | name: 'controllerPath', 37 | message: '(4/4) Path to Controller:', 38 | default: '/hello-world' 39 | } 40 | ] 41 | 42 | this.prompt(prompts, function (props) { 43 | this.packageName = props.packageName; 44 | this.viewName = props.viewName; 45 | this.controllerName = props.controllerName; 46 | this.controllerPath = props.controllerPath; 47 | cb(); 48 | }.bind(this)); 49 | 50 | }; 51 | 52 | RestGenerator.prototype.files = function app() { 53 | var packageFolder = this.packageName.replace(/\./g, '/'); 54 | var controllersDir = 'src/main/java/' + packageFolder + '/controller'; 55 | var viewsDir = 'src/main/resources/templates'; 56 | 57 | mkdirp(controllersDir); 58 | mkdirp(viewsDir); 59 | 60 | this.template('Controller.java', controllersDir + '/' + this.controllerName + '.java'); 61 | this.template('view.html', viewsDir + '/' + this.viewName + '.html'); 62 | 63 | this.config.set('packageName', this.packageName); 64 | }; 65 | -------------------------------------------------------------------------------- /route/templates/Controller.java: -------------------------------------------------------------------------------- 1 | package <%= packageName %>.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @Controller 9 | public class <%= controllerName %> { 10 | 11 | @RequestMapping("<%= controllerPath %>") 12 | public String process(@RequestParam(value = "content", required = false, defaultValue = "content") String content, Model model) { 13 | model.addAttribute("content", content); 14 | return "<%= viewName %>"; 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /route/templates/view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

8 | 9 | -------------------------------------------------------------------------------- /test/test-load.js: -------------------------------------------------------------------------------- 1 | /*global describe, beforeEach, it*/ 2 | 'use strict'; 3 | 4 | var assert = require('assert'); 5 | 6 | describe('spring generator', function () { 7 | it('can be imported without blowing up', function () { 8 | var app = require('../app'); 9 | assert(app !== undefined); 10 | }); 11 | }); 12 | --------------------------------------------------------------------------------