• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

How to create the application.properties file in a Spring Boot project?

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Eclipse to develop a Spring Boot with devtools project, and I get the following error when I try to run it:


***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


I suspect the main reason for this is that I don't have an application.properties file in the src/main/resources folder. I tried to right-click-new, but nothing pops up that gives me the option to create a .properties file manually. Do I need to configure a build path to get this file created? If so, how do I do that once I'm in the Java Build Path menu?
 
Sheriff
Posts: 21805
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just create a new "File" and name it application.properties. You can do that with any file that doesn't have a special editor. I even do it for new XML files.

And welcome to the Ranch!
 
Sam Peterson
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still having issues launching my Spring Boot application:

properties file:

pom.xml file:


[Console Output]
***************************
APPLICATION FAILED TO START
***************************

Description:

Field MMR in sam.springboot.service.MedicalMemberService required a bean of type 'sam.springboot.dao.MedicalMemberRepo' that could not be found.

The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'sam.springboot.dao.MedicalMemberRepo' in your configuration.
[/Console Output]

MedicalMemberRepo class:


MedicalMemberService class:

As you can see on lines 16 and 22, I've added the @Bean annotations, but it gives the error, "The annotation @Bean is disallowed for this location".
What am I missing?
 
Rancher
Posts: 500
6
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You dont need to use @bean.   Just have the auto wired and it will find the bean.  Also why do you have the repo annotated with @configuration.  Did you put configurations in there ?  Dont know why that would ever be a good idea.  
The bean annotation is used for creating beans to be used in places like the service.  Not for injection.  Heres the docs : https://docs.spring.io/spring-javaconfig/docs/1.0.0.M4/reference/html/ch02s02.html
 
Rob Spoor
Sheriff
Posts: 21805
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What package is your @SpringBootApplication in? Is it sam.springboot, or something else? If it's something else, what packages is it scanning?
 
Don't touch me. And dont' touch this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!