Skip to content

Instantly share code, notes, and snippets.

View dev.yml
url: https://nullpointerexception1.wordpress.com/
View MyApplication.java
import io.dropwizard.Application;
import io.dropwizard.setup.Environment;
/**
* Created by harshvardhan on 12/07/18.
*/
public class MyApplication extends Application<MyConfiguration> {
public static void main(String[] args) throws Exception {
new MyApplication().run(args);
View MyResource.java
import com.codahale.metrics.annotation.Timed;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
/**
* Created by harshvardhan on 12/07/18.
*/
@Path("/resource")
View MyApplication.java
import io.dropwizard.Application;
import io.dropwizard.setup.Environment;
/**
* Created by harshvardhan on 12/07/18.
*/
public class MyApplication extends Application<MyConfiguration> {
public static void main(String[] args) throws Exception {
new MyApplication().run(args);
View pom.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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordpress.nullpointerexception1</groupId>
<artifactId>myRestProject</artifactId>
<version>1.0-SNAPSHOT</version>
View info.sql
CREATE TABLE `info` (
`name` varchar(50) NOT NULL DEFAULT '',
`empid` varchar(50) NOT NULL DEFAULT '',
PRIMARY KEY (`empid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
View Info.java
package models;
import lombok.Data;
import javax.persistence.*;
/**
* Created by harshvardhan on 10/07/18.
*/
@Entity
View InfoDao.java
import io.dropwizard.hibernate.AbstractDAO;
import org.hibernate.SessionFactory;
import java.util.List;
/**
* Created by harshvardhan on 10/07/18.
*/
public class InfoDao extends AbstractDAO<Info> {
View MyConfiguration.java
import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.Configuration;
import io.dropwizard.db.DataSourceFactory;
/**
* Created by harshvardhan on 12/07/18.
*/
public class MyConfiguration extends Configuration {
private String url;
View MyApplication.java
import io.dropwizard.Application;
import io.dropwizard.db.DataSourceFactory;
import io.dropwizard.hibernate.HibernateBundle;
import io.dropwizard.setup.Environment;
/**
* Created by harshvardhan on 12/07/18.
*/
public class MyApplication extends Application<MyConfiguration> {