I'm struggling to learn how I go about building, packaging, and deploying a Spring REST API locally so that I can interact with it? Ideally, I'd just like to GET and POST data as practice -- specifically integrating with DynamoDB.
I've cloned this DynamoDB project and built it using mvn package so that I have a jar file. I moved the jar file to the webapp directory of Apache and started the server, but I cannot interact with the API in any way. The project is structured as follows:
Once Apache is running with the jar in the webapp directory, I've tried accessing the API at:
http://localhost:8080/
http://localhost:8080/springbootapp (from server.contextPath=/springbootapp in application.properties)
Each gives a 404 error. And yes, DynamoDB is running locally. So what do I need to do differently? How can I deploy and access this API locally?
The project you have cloned is a spring boot project, hence you can use mvn spring-boot:run to run the application locally.You can also run it by running the com.baeldung.Application class as a java application from the IDE. For more details on how to run a spring boot app you can follow this link. Spring boot parent has a dependency on the embedded tomcat, which will run the application.
Additionally if you want to deploy the application as a war the spring boot documentation shows how to do it.
Related
Since App Engine reached the end of life last August on the 30th, it's not possible anymore to deploy updates to the same application using the appengine (appcfg) command line.
I was using the appengine maven plugin which in turn was using appcfg to deploy my application.
I'm looking on how to migrate my application to Google Cloud SDK now but between the limitations I saw that Google Cloud SDK does not support EAR applications to be deployed.
Surprize surprize my applications does have an EAR structure.
Is there a workaround for this or should I completely change the structure of my application?
You don't have to change your application structure at all. It's only the deployment that it slightly altered.
Before, you used to create war artifacts and package them into a deployable ear.
Now you keep creating the same war artifacts but you must not package them into an ear. Instead, you deploy them all together using the gcloud command:
gcloud app deploy ./path_module1/WEB-INF/appengine-web.xml ./path_module2/WEB-INF/appengine-web.xml
path_moduleX are paths to the exploded artifacts (not path to your source code, of course)
as explained here https://cloud.google.com/appengine/docs/standard/java/configuration-files
I am new to spring boot and I would want to know the basics of it. I am creating a project with jHipster. When I install gulp on my system I can see the project running at port 9000. I however want to deploy the same application on my local using tomcat apache server.
Can I debug my code in java using the same server installed during the time of spring boot or do I need a separate server like apache?
From JHipster documentation "Profiles" :
If you're using Maven Wrapper (mvnw)
./mvnw package
If you're using Gradle Wrapper (mvnw)
./gradlew bootRepackage
Should produce WAR with development profile as
By default, JHipster will use the dev profile
I think you can deploy this WAR on your usual Tomcat
I have a WAR with Java Spring application, which I can deploy to a Java application server. I need to run it on a machine with JRE, but without application server, i.e. with java -jar my_application.jar.
The guide "Convert an existing application to Spring Boot" is a close match, except that I do not need to create a deployable WAR as I already have it. The existing code does not use #SpringBootApplication, and I'd prefer not to mangle with it.
If you want a runnable 'Jar' file, then the jar file must contain the Web server, so you best option is to convert your application to spring boot. Spring boot is able to package an application as a war file, so it can be deployed on a Tomcat, or be launched with java -jar, but it has to be a spring boot app to begin with.
I have a spring app that i am running on local tomcat using maven/intellij. I wanted to deploy it on heorko. When i just pushed the app (without any main class or procfile) i got the error that there is no application running.
I then followed this tutorial https://devcenter.heroku.com/articles/create-a-java-web-application-using-embedded-tomcat
and added changes to pom.xml, created a Main.java class as suggested and created a procfile on root (where the pom.xml file is) and then i pushed it to heroku. I got the same error that application isn't running.
How can i run a spring tomcat app on heroku.
p.s:
Spring configurations are done using <project_name>Configuration.java class and <project_name>Initializer.java.
Try following the guide for Deploying Spring Boot Applications to Heroku. If you're deploying a WAR file, try following the guide for Deploying WAR Files. Otherwise, you'll need to provide more info about your app.
I have Jenkins CI configured with a SVN repo of our Java EE based application.
I am able to build the application but I am facing problems while deploying the war. Actually I don't have any idea how to get a war file out of the build and deploy it to a remote Tomcat 7 server.
I need to deploy this code to Tomcat 7 in the form of a war deployment. Please guide me through any tutorial or docs.
If your build is Maven based, you could use the Maven Tomcat plugin. This will do more or less the same actions as the Jenkins Deploy plugin, but it will add a dependency on your build tool and not on your continuous integration tool.
There's a plugin for that: https://wiki.jenkins-ci.org/display/JENKINS/Deploy+Plugin
Basically, the deploy plugin will use tomcat's built in REST API/manager application to deploy the war file.
I use this in anger, and it's pretty simple. The plugin does everything you'll need for a simple situation.
If your needs are more complicated than this, you can script access to the management REST API directly, but I advise you to start with the plugin.