netodevel / cli-spring-boot-scaffold

command line for generate crud and configs for spring boot projects
131 stars 49 forks source link

Creating new Rest Controller #34

Closed 8904591612 closed 7 years ago

8904591612 commented 7 years ago

Hii My requirement is such that I need to create a rest controller also , while scaffolding along with Model, Controller Repository , Service ,I went through the procedure that is used to generate the files given the command. I followed the same steps.

  1. I created the file "template-rest-controller.txt" in spring-boot-generate projects resources/templates/java/rest folder
  2. I created a java class RestGenerator.java inside br.com.generate.java.command.rest package.
  3. I created an object of same class in br.com.netodevel.scaffold.ScaffoldHandler.java This is how I gave . new RestGenerator().generate(nameClass, null, "template-rest-controller.txt");

But when I create a new project , it is not creating the rest controller .. What should I do I am unable to make out. Please Help This is the link to my repository.

https://github.com/8904591612/spring-scaffold-5

netodevel commented 7 years ago

Hi @8904591612 , what is the output when executed generate?

8904591612 commented 7 years ago

It generates all files except the rest controller, the same way as it was generated before I made the changes.I mean the changes I have made are not getting reflected .

netodevel commented 7 years ago

I ran your project and it is generating the rest file.

Output:

create src/main/java/br/com/example/model/UserModelModel.java
create src/main/java/br/com/example/repository/UserModelRepository.java
create src/main/java/br/com/example/service/UserModelService.java
create src/main/java/br/com/example/controller/UserModelController.java
create src/main/java/br/com/example/rest/UserModelRest.java
create /src/main/resources/templates/layout.html
create /src/main/resources/templates/usermodel/index.html
create /src/main/resources/templates/usermodel/form.html
create /src/main/resources/templates/usermodel/show.html
migration created migrations/create_UserModel_table.sql
netodevel commented 7 years ago

@8904591612 Please use git flow, make a fork and when you finish your feature, open pull request.

8904591612 commented 7 years ago

Hii. Ya sure I will follow the conventions,I have a small confusion,From where should I compile the code. Currently I have in .m2 directory. I made the changes , ran "clean compile install" and created the new project and the scaffold, but the same ,my changes are not reflected, What should I do, since this is the first time I am editting a source code,Please help. What is mean I compiled the code by changing , but I am getting the same output are there any other changes I should make to run the code?

Thanks

netodevel commented 7 years ago

@8904591612 try to execute these commands in order inside repository:

spring uninstall br.com.netodevel:spring-scaffold-cli:0.0.1-SNAPSHOT
mvn install
spring install br.com.netodevel:spring-scaffold-cli:0.0.1-SNAPSHOT
8904591612 commented 7 years ago

Hii. Thanks a lot I fixed the issue .My code was running from lib directory , which was the previous version, but latest code was in opt/spring-boot/spring-1.4.0.RELEASE/lib/ext directory. That was the issue.