• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 86
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 86
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 667
14
TypeScript Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic