Can you share an example of the command you are executing from the command 
line (or IDE program arguments) that you are using?

The getting started guide walks through an example using the out-of-the-box 
"server" command (
https://www.dropwizard.io/en/latest/getting-started.html#running-your-application).
 
In that case you have something like the following:

java -jar target/hello-world-0.0.1-SNAPSHOT.jar server hello-world.yml

In the case of using your custom command, you'd need to pass the command 
name as the first argument (in place of "server"). For example:

java -jar target/hello-world-0.0.1-SNAPSHOT.jar ganesh



On Tuesday, March 3, 2020 at 11:31:42 AM UTC-8, rshukla21 wrote:
>
> Dear Friends,
> I am new to dropwizard and have to modify something into existing 
> application classes.
>
> 1. I want to execute my command class when my main application class gets 
> executed as in my custom command class I have create database tables on run 
> time.
> 2. While I write Bootstrap.addCommand((new MyCommand("ganesh", "ram")); , 
> this will create instance but run method of MyCommand is not getting 
> executed, am I missing something here to add some code?
>
> Code Examples which I am trying.
>
> public class App extends Application<MyConfig> {
> private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
>
> @Override
> public void initialize(Bootstrap<MyConfig> b) {
> System.out.println(">>inside initialize");
> b.addCommand(new MyCommand("ganesh", "ram"));
> }
>
> @Override
> public void run(MyConfig c, Environment e) throws Exception 
> {
> // here some more statements which gets executed when App class runs.
>
>        }
> }
>
> //Command class
>
> public class MyCommand extends ConfiguredCommand<MyConfig>{
>
> protected MyCommand(String name, String description) {
> super(name, description);
> // TODO Auto-generated constructor stub
> }
>
> @Override
> protected void run(Bootstrap<MyConfig> bootstrap, Namespace namespace, 
> MyConfig configuration)
> throws Exception {
> //Here I will write code to creat tables but how this run method will 
> execute automatically?
> }
>
> }
>
>
> Thanks,
> Ram
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dropwizard-user/7d43583c-8604-4325-a9d4-dee7449d3186%40googlegroups.com.

Reply via email to