Unable to make POST request in Spring Boot
I am trying to create webservices in JAVA Spring boot with backend as SQL Server 2012. I followed the tutorial from this website https://www.callicoder.com/spring-boot-rest-api-tutorial-with-mysql-jpa-hibernate/.
The only change i did was, changed the application.properties as
spring.datasource.url=jdbc:sqlserver://localhost;databaseName=SampleSpringDB
spring.datasource.username=sa
spring.datasource.password=sqlpassword
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.jpa.hibernate.ddl-auto = create-drop
Tomcat does not show any errors while running the app.
While testing POST method in Postman i get error in postman as
{
"timestamp": "2018-11-21T04:44:06.474+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/api/notes/"
}
The code is totally copied from the above mentioned site.
Code for Controller
@RestController
@RequestMapping(value="/api", produces="application/json")
public class NoteController {
@Autowired
NoteRepository noteRepository;
// Create Note
@PostMapping("/notes")
public Note createNote(@Valid @RequestBody Note note) {
return noteRepository.save(note);
}
// Get all notes
@GetMapping("/notes")
public List<Note> getAllNotes() {
return noteRepository.findAll();
}
// Get Single Note
@GetMapping("/notes/{id}")
public Note getNoteById(@PathVariable(value = "id") Long noteID) {
return noteRepository.findById(noteID).orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteID));
}
// Update Note
@PutMapping("/notes/{id}")
public Note updateNote(@PathVariable(value = "id") Long noteID, @RequestBody Note noteDetails) {
Note note = noteRepository.findById(noteID)
.orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteID));
note.setTitle(noteDetails.getTitle());
note.setContent(noteDetails.getContent());
Note updatedNote = noteRepository.save(note);
return (updatedNote);
}
// Delete Note
@DeleteMapping("/notes/{id}")
public ResponseEntity<?> deleteNote(@PathVariable(value = "id") Long noteID) {
Note note = noteRepository.findById(noteID)
.orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteID));
noteRepository.delete(note);
return ResponseEntity.ok().build();
}
}
POSTMAN POST url
localhost:8080/api/notes/
body params as {"title":"test","content":"test"}
java hibernate spring-boot sql-server-2012
|
show 10 more comments
I am trying to create webservices in JAVA Spring boot with backend as SQL Server 2012. I followed the tutorial from this website https://www.callicoder.com/spring-boot-rest-api-tutorial-with-mysql-jpa-hibernate/.
The only change i did was, changed the application.properties as
spring.datasource.url=jdbc:sqlserver://localhost;databaseName=SampleSpringDB
spring.datasource.username=sa
spring.datasource.password=sqlpassword
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.jpa.hibernate.ddl-auto = create-drop
Tomcat does not show any errors while running the app.
While testing POST method in Postman i get error in postman as
{
"timestamp": "2018-11-21T04:44:06.474+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/api/notes/"
}
The code is totally copied from the above mentioned site.
Code for Controller
@RestController
@RequestMapping(value="/api", produces="application/json")
public class NoteController {
@Autowired
NoteRepository noteRepository;
// Create Note
@PostMapping("/notes")
public Note createNote(@Valid @RequestBody Note note) {
return noteRepository.save(note);
}
// Get all notes
@GetMapping("/notes")
public List<Note> getAllNotes() {
return noteRepository.findAll();
}
// Get Single Note
@GetMapping("/notes/{id}")
public Note getNoteById(@PathVariable(value = "id") Long noteID) {
return noteRepository.findById(noteID).orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteID));
}
// Update Note
@PutMapping("/notes/{id}")
public Note updateNote(@PathVariable(value = "id") Long noteID, @RequestBody Note noteDetails) {
Note note = noteRepository.findById(noteID)
.orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteID));
note.setTitle(noteDetails.getTitle());
note.setContent(noteDetails.getContent());
Note updatedNote = noteRepository.save(note);
return (updatedNote);
}
// Delete Note
@DeleteMapping("/notes/{id}")
public ResponseEntity<?> deleteNote(@PathVariable(value = "id") Long noteID) {
Note note = noteRepository.findById(noteID)
.orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteID));
noteRepository.delete(note);
return ResponseEntity.ok().build();
}
}
POSTMAN POST url
localhost:8080/api/notes/
body params as {"title":"test","content":"test"}
java hibernate spring-boot sql-server-2012
Please post your controller code and the URL which are hitting in postman.
– Jignesh M. Khatri
Nov 21 '18 at 5:08
Try:localhost:8080/api/notes
. Removing trailing forward slash
– Jignesh M. Khatri
Nov 21 '18 at 5:12
This was the application.properties in that website spring.datasource.url = jdbc:mysql://localhost:3306/notes_app?useSSL=false spring.datasource.username = root spring.datasource.password = root ## Hibernate Properties # The SQL dialect makes Hibernate generate better SQL for the chosen database spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect # Hibernate ddl auto (create, create-drop, validate, update) spring.jpa.hibernate.ddl-auto = update
– rahul ramakrishnan
Nov 21 '18 at 5:12
can you shate Note class?
– GauravRai1512
Nov 21 '18 at 5:14
localhost:8080/api/notes was also tested but got same error @JigneshM.Khatri
– rahul ramakrishnan
Nov 21 '18 at 5:14
|
show 10 more comments
I am trying to create webservices in JAVA Spring boot with backend as SQL Server 2012. I followed the tutorial from this website https://www.callicoder.com/spring-boot-rest-api-tutorial-with-mysql-jpa-hibernate/.
The only change i did was, changed the application.properties as
spring.datasource.url=jdbc:sqlserver://localhost;databaseName=SampleSpringDB
spring.datasource.username=sa
spring.datasource.password=sqlpassword
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.jpa.hibernate.ddl-auto = create-drop
Tomcat does not show any errors while running the app.
While testing POST method in Postman i get error in postman as
{
"timestamp": "2018-11-21T04:44:06.474+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/api/notes/"
}
The code is totally copied from the above mentioned site.
Code for Controller
@RestController
@RequestMapping(value="/api", produces="application/json")
public class NoteController {
@Autowired
NoteRepository noteRepository;
// Create Note
@PostMapping("/notes")
public Note createNote(@Valid @RequestBody Note note) {
return noteRepository.save(note);
}
// Get all notes
@GetMapping("/notes")
public List<Note> getAllNotes() {
return noteRepository.findAll();
}
// Get Single Note
@GetMapping("/notes/{id}")
public Note getNoteById(@PathVariable(value = "id") Long noteID) {
return noteRepository.findById(noteID).orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteID));
}
// Update Note
@PutMapping("/notes/{id}")
public Note updateNote(@PathVariable(value = "id") Long noteID, @RequestBody Note noteDetails) {
Note note = noteRepository.findById(noteID)
.orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteID));
note.setTitle(noteDetails.getTitle());
note.setContent(noteDetails.getContent());
Note updatedNote = noteRepository.save(note);
return (updatedNote);
}
// Delete Note
@DeleteMapping("/notes/{id}")
public ResponseEntity<?> deleteNote(@PathVariable(value = "id") Long noteID) {
Note note = noteRepository.findById(noteID)
.orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteID));
noteRepository.delete(note);
return ResponseEntity.ok().build();
}
}
POSTMAN POST url
localhost:8080/api/notes/
body params as {"title":"test","content":"test"}
java hibernate spring-boot sql-server-2012
I am trying to create webservices in JAVA Spring boot with backend as SQL Server 2012. I followed the tutorial from this website https://www.callicoder.com/spring-boot-rest-api-tutorial-with-mysql-jpa-hibernate/.
The only change i did was, changed the application.properties as
spring.datasource.url=jdbc:sqlserver://localhost;databaseName=SampleSpringDB
spring.datasource.username=sa
spring.datasource.password=sqlpassword
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.jpa.hibernate.ddl-auto = create-drop
Tomcat does not show any errors while running the app.
While testing POST method in Postman i get error in postman as
{
"timestamp": "2018-11-21T04:44:06.474+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/api/notes/"
}
The code is totally copied from the above mentioned site.
Code for Controller
@RestController
@RequestMapping(value="/api", produces="application/json")
public class NoteController {
@Autowired
NoteRepository noteRepository;
// Create Note
@PostMapping("/notes")
public Note createNote(@Valid @RequestBody Note note) {
return noteRepository.save(note);
}
// Get all notes
@GetMapping("/notes")
public List<Note> getAllNotes() {
return noteRepository.findAll();
}
// Get Single Note
@GetMapping("/notes/{id}")
public Note getNoteById(@PathVariable(value = "id") Long noteID) {
return noteRepository.findById(noteID).orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteID));
}
// Update Note
@PutMapping("/notes/{id}")
public Note updateNote(@PathVariable(value = "id") Long noteID, @RequestBody Note noteDetails) {
Note note = noteRepository.findById(noteID)
.orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteID));
note.setTitle(noteDetails.getTitle());
note.setContent(noteDetails.getContent());
Note updatedNote = noteRepository.save(note);
return (updatedNote);
}
// Delete Note
@DeleteMapping("/notes/{id}")
public ResponseEntity<?> deleteNote(@PathVariable(value = "id") Long noteID) {
Note note = noteRepository.findById(noteID)
.orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteID));
noteRepository.delete(note);
return ResponseEntity.ok().build();
}
}
POSTMAN POST url
localhost:8080/api/notes/
body params as {"title":"test","content":"test"}
java hibernate spring-boot sql-server-2012
java hibernate spring-boot sql-server-2012
edited Nov 23 '18 at 9:31


FrankerZ
16.9k72862
16.9k72862
asked Nov 21 '18 at 5:05


rahul ramakrishnanrahul ramakrishnan
198
198
Please post your controller code and the URL which are hitting in postman.
– Jignesh M. Khatri
Nov 21 '18 at 5:08
Try:localhost:8080/api/notes
. Removing trailing forward slash
– Jignesh M. Khatri
Nov 21 '18 at 5:12
This was the application.properties in that website spring.datasource.url = jdbc:mysql://localhost:3306/notes_app?useSSL=false spring.datasource.username = root spring.datasource.password = root ## Hibernate Properties # The SQL dialect makes Hibernate generate better SQL for the chosen database spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect # Hibernate ddl auto (create, create-drop, validate, update) spring.jpa.hibernate.ddl-auto = update
– rahul ramakrishnan
Nov 21 '18 at 5:12
can you shate Note class?
– GauravRai1512
Nov 21 '18 at 5:14
localhost:8080/api/notes was also tested but got same error @JigneshM.Khatri
– rahul ramakrishnan
Nov 21 '18 at 5:14
|
show 10 more comments
Please post your controller code and the URL which are hitting in postman.
– Jignesh M. Khatri
Nov 21 '18 at 5:08
Try:localhost:8080/api/notes
. Removing trailing forward slash
– Jignesh M. Khatri
Nov 21 '18 at 5:12
This was the application.properties in that website spring.datasource.url = jdbc:mysql://localhost:3306/notes_app?useSSL=false spring.datasource.username = root spring.datasource.password = root ## Hibernate Properties # The SQL dialect makes Hibernate generate better SQL for the chosen database spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect # Hibernate ddl auto (create, create-drop, validate, update) spring.jpa.hibernate.ddl-auto = update
– rahul ramakrishnan
Nov 21 '18 at 5:12
can you shate Note class?
– GauravRai1512
Nov 21 '18 at 5:14
localhost:8080/api/notes was also tested but got same error @JigneshM.Khatri
– rahul ramakrishnan
Nov 21 '18 at 5:14
Please post your controller code and the URL which are hitting in postman.
– Jignesh M. Khatri
Nov 21 '18 at 5:08
Please post your controller code and the URL which are hitting in postman.
– Jignesh M. Khatri
Nov 21 '18 at 5:08
Try:
localhost:8080/api/notes
. Removing trailing forward slash– Jignesh M. Khatri
Nov 21 '18 at 5:12
Try:
localhost:8080/api/notes
. Removing trailing forward slash– Jignesh M. Khatri
Nov 21 '18 at 5:12
This was the application.properties in that website spring.datasource.url = jdbc:mysql://localhost:3306/notes_app?useSSL=false spring.datasource.username = root spring.datasource.password = root ## Hibernate Properties # The SQL dialect makes Hibernate generate better SQL for the chosen database spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect # Hibernate ddl auto (create, create-drop, validate, update) spring.jpa.hibernate.ddl-auto = update
– rahul ramakrishnan
Nov 21 '18 at 5:12
This was the application.properties in that website spring.datasource.url = jdbc:mysql://localhost:3306/notes_app?useSSL=false spring.datasource.username = root spring.datasource.password = root ## Hibernate Properties # The SQL dialect makes Hibernate generate better SQL for the chosen database spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect # Hibernate ddl auto (create, create-drop, validate, update) spring.jpa.hibernate.ddl-auto = update
– rahul ramakrishnan
Nov 21 '18 at 5:12
can you shate Note class?
– GauravRai1512
Nov 21 '18 at 5:14
can you shate Note class?
– GauravRai1512
Nov 21 '18 at 5:14
localhost:8080/api/notes was also tested but got same error @JigneshM.Khatri
– rahul ramakrishnan
Nov 21 '18 at 5:14
localhost:8080/api/notes was also tested but got same error @JigneshM.Khatri
– rahul ramakrishnan
Nov 21 '18 at 5:14
|
show 10 more comments
3 Answers
3
active
oldest
votes
Can you do a quick check whether you added @SpringBootApplication
:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
@SpringBootApplication includes @ComponentScan which scans the package it's in and all children packages. Your controller may not be in any of them.
The below annotaions are there on the class SpringBootApplication EnableJpaAuditing ComponentScan(basePackageClasses=NoteRepository.class)
– rahul ramakrishnan
Nov 21 '18 at 7:09
remove@ComponentScan
and check again and try to have all your classes in one package
– Vipul Kumar
Nov 21 '18 at 7:19
add a comment |
Did you added sqlserver connector at pom.xml? If added please skip this answer and I will remove this. I tested your code on mysql server its working fine.
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
i added <dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>mssql-jdbc</artifactId> <version>6.2.2.jre8</version> </dependency> I did not try out your method. Will try it out and give an update
– rahul ramakrishnan
Nov 21 '18 at 12:31
add a comment |
This issue has been fixed (In a Weird way)
I created the same project with backend as MySQL and tested out the service. It worked fine. Then i added SQL server dependency
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
into pom.xml and changed the application.properties to
spring.datasource.url=jdbc:sqlserver://localhost;databaseName=SampleSpringDB
spring.datasource.username=sa
spring.datasource.password=password
spring.datasource.driverClassName=
com.microsoft.sqlserver.jdbc.SQLServerDriver spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=
org.hibernate.dialect.SQLServer2012Dialect spring.jpa.hibernate.ddl-auto
= create-drop
By doing so it worked out fine.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405559%2funable-to-make-post-request-in-spring-boot%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Can you do a quick check whether you added @SpringBootApplication
:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
@SpringBootApplication includes @ComponentScan which scans the package it's in and all children packages. Your controller may not be in any of them.
The below annotaions are there on the class SpringBootApplication EnableJpaAuditing ComponentScan(basePackageClasses=NoteRepository.class)
– rahul ramakrishnan
Nov 21 '18 at 7:09
remove@ComponentScan
and check again and try to have all your classes in one package
– Vipul Kumar
Nov 21 '18 at 7:19
add a comment |
Can you do a quick check whether you added @SpringBootApplication
:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
@SpringBootApplication includes @ComponentScan which scans the package it's in and all children packages. Your controller may not be in any of them.
The below annotaions are there on the class SpringBootApplication EnableJpaAuditing ComponentScan(basePackageClasses=NoteRepository.class)
– rahul ramakrishnan
Nov 21 '18 at 7:09
remove@ComponentScan
and check again and try to have all your classes in one package
– Vipul Kumar
Nov 21 '18 at 7:19
add a comment |
Can you do a quick check whether you added @SpringBootApplication
:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
@SpringBootApplication includes @ComponentScan which scans the package it's in and all children packages. Your controller may not be in any of them.
Can you do a quick check whether you added @SpringBootApplication
:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
@SpringBootApplication includes @ComponentScan which scans the package it's in and all children packages. Your controller may not be in any of them.
answered Nov 21 '18 at 6:58
Vipul KumarVipul Kumar
14
14
The below annotaions are there on the class SpringBootApplication EnableJpaAuditing ComponentScan(basePackageClasses=NoteRepository.class)
– rahul ramakrishnan
Nov 21 '18 at 7:09
remove@ComponentScan
and check again and try to have all your classes in one package
– Vipul Kumar
Nov 21 '18 at 7:19
add a comment |
The below annotaions are there on the class SpringBootApplication EnableJpaAuditing ComponentScan(basePackageClasses=NoteRepository.class)
– rahul ramakrishnan
Nov 21 '18 at 7:09
remove@ComponentScan
and check again and try to have all your classes in one package
– Vipul Kumar
Nov 21 '18 at 7:19
The below annotaions are there on the class SpringBootApplication EnableJpaAuditing ComponentScan(basePackageClasses=NoteRepository.class)
– rahul ramakrishnan
Nov 21 '18 at 7:09
The below annotaions are there on the class SpringBootApplication EnableJpaAuditing ComponentScan(basePackageClasses=NoteRepository.class)
– rahul ramakrishnan
Nov 21 '18 at 7:09
remove
@ComponentScan
and check again and try to have all your classes in one package– Vipul Kumar
Nov 21 '18 at 7:19
remove
@ComponentScan
and check again and try to have all your classes in one package– Vipul Kumar
Nov 21 '18 at 7:19
add a comment |
Did you added sqlserver connector at pom.xml? If added please skip this answer and I will remove this. I tested your code on mysql server its working fine.
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
i added <dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>mssql-jdbc</artifactId> <version>6.2.2.jre8</version> </dependency> I did not try out your method. Will try it out and give an update
– rahul ramakrishnan
Nov 21 '18 at 12:31
add a comment |
Did you added sqlserver connector at pom.xml? If added please skip this answer and I will remove this. I tested your code on mysql server its working fine.
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
i added <dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>mssql-jdbc</artifactId> <version>6.2.2.jre8</version> </dependency> I did not try out your method. Will try it out and give an update
– rahul ramakrishnan
Nov 21 '18 at 12:31
add a comment |
Did you added sqlserver connector at pom.xml? If added please skip this answer and I will remove this. I tested your code on mysql server its working fine.
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
Did you added sqlserver connector at pom.xml? If added please skip this answer and I will remove this. I tested your code on mysql server its working fine.
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
answered Nov 21 '18 at 7:46
flopcoderflopcoder
735512
735512
i added <dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>mssql-jdbc</artifactId> <version>6.2.2.jre8</version> </dependency> I did not try out your method. Will try it out and give an update
– rahul ramakrishnan
Nov 21 '18 at 12:31
add a comment |
i added <dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>mssql-jdbc</artifactId> <version>6.2.2.jre8</version> </dependency> I did not try out your method. Will try it out and give an update
– rahul ramakrishnan
Nov 21 '18 at 12:31
i added <dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>mssql-jdbc</artifactId> <version>6.2.2.jre8</version> </dependency> I did not try out your method. Will try it out and give an update
– rahul ramakrishnan
Nov 21 '18 at 12:31
i added <dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>mssql-jdbc</artifactId> <version>6.2.2.jre8</version> </dependency> I did not try out your method. Will try it out and give an update
– rahul ramakrishnan
Nov 21 '18 at 12:31
add a comment |
This issue has been fixed (In a Weird way)
I created the same project with backend as MySQL and tested out the service. It worked fine. Then i added SQL server dependency
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
into pom.xml and changed the application.properties to
spring.datasource.url=jdbc:sqlserver://localhost;databaseName=SampleSpringDB
spring.datasource.username=sa
spring.datasource.password=password
spring.datasource.driverClassName=
com.microsoft.sqlserver.jdbc.SQLServerDriver spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=
org.hibernate.dialect.SQLServer2012Dialect spring.jpa.hibernate.ddl-auto
= create-drop
By doing so it worked out fine.
add a comment |
This issue has been fixed (In a Weird way)
I created the same project with backend as MySQL and tested out the service. It worked fine. Then i added SQL server dependency
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
into pom.xml and changed the application.properties to
spring.datasource.url=jdbc:sqlserver://localhost;databaseName=SampleSpringDB
spring.datasource.username=sa
spring.datasource.password=password
spring.datasource.driverClassName=
com.microsoft.sqlserver.jdbc.SQLServerDriver spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=
org.hibernate.dialect.SQLServer2012Dialect spring.jpa.hibernate.ddl-auto
= create-drop
By doing so it worked out fine.
add a comment |
This issue has been fixed (In a Weird way)
I created the same project with backend as MySQL and tested out the service. It worked fine. Then i added SQL server dependency
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
into pom.xml and changed the application.properties to
spring.datasource.url=jdbc:sqlserver://localhost;databaseName=SampleSpringDB
spring.datasource.username=sa
spring.datasource.password=password
spring.datasource.driverClassName=
com.microsoft.sqlserver.jdbc.SQLServerDriver spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=
org.hibernate.dialect.SQLServer2012Dialect spring.jpa.hibernate.ddl-auto
= create-drop
By doing so it worked out fine.
This issue has been fixed (In a Weird way)
I created the same project with backend as MySQL and tested out the service. It worked fine. Then i added SQL server dependency
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
into pom.xml and changed the application.properties to
spring.datasource.url=jdbc:sqlserver://localhost;databaseName=SampleSpringDB
spring.datasource.username=sa
spring.datasource.password=password
spring.datasource.driverClassName=
com.microsoft.sqlserver.jdbc.SQLServerDriver spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=
org.hibernate.dialect.SQLServer2012Dialect spring.jpa.hibernate.ddl-auto
= create-drop
By doing so it worked out fine.
answered Nov 23 '18 at 9:28


rahul ramakrishnanrahul ramakrishnan
198
198
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405559%2funable-to-make-post-request-in-spring-boot%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please post your controller code and the URL which are hitting in postman.
– Jignesh M. Khatri
Nov 21 '18 at 5:08
Try:
localhost:8080/api/notes
. Removing trailing forward slash– Jignesh M. Khatri
Nov 21 '18 at 5:12
This was the application.properties in that website spring.datasource.url = jdbc:mysql://localhost:3306/notes_app?useSSL=false spring.datasource.username = root spring.datasource.password = root ## Hibernate Properties # The SQL dialect makes Hibernate generate better SQL for the chosen database spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect # Hibernate ddl auto (create, create-drop, validate, update) spring.jpa.hibernate.ddl-auto = update
– rahul ramakrishnan
Nov 21 '18 at 5:12
can you shate Note class?
– GauravRai1512
Nov 21 '18 at 5:14
localhost:8080/api/notes was also tested but got same error @JigneshM.Khatri
– rahul ramakrishnan
Nov 21 '18 at 5:14