I went through a project structure in STS where I could see a MVC pattern where controller, service,Dao , entity classes were there. But looking at pom.xml got to know that it is a web application project. But how to confirm that it is not a spring boot application..?
I m new to spring boot. All I found is there were no starter dependencies in pom.xml or any dependency has word "boot" & there was not a main method where a spring boot project starts.
So my question is which particular dependency/ parameters differentiates spring boot application from a non spring boot application ?
In general in the first part of the pom.xml you can see this tag:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<relativePath />
<!-- lookup parent from repository -->
</parent>
Check the pom.xml. see if it includes the spring boot dependency or any other Spring boot dependency flavors like Spring-boot-starter, spring-boot-autoconfigure,spring-boot-web etc....
Basically anything with group ID
"org.springframework.boot"
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.3.1.RELEASE</version>
</dependency>
Additionally also look for the #SpringBootApplication annotation on top of the main class.
If you're running a Gradle project, you might see something like this inside of one of your build.gradle (or [projectName].gradle) files.
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
Or maybe
apply plugin: 'org.springframework.boot'
The above advice to search globally for org.springframework.boot is sound, just wanted to stress there might not be a pom.xml (or any .xml) files present.
Related
I have to write a small project, which is not runnable by itself, but it is used by some other ("main") project as dependency to do some database operations and some simple business logic. So there will be no actual main class in my project, only some API, which will be used by the main project. Now I was wondering, if it is possible, to use Spring Boot with Spring Data JPA in my small project for Database operations. So there will be no #SpringBootApplication annotated class. (And the main project is also not a Spring Boot application)
So I actually modified my pom.xml by adding this:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
(...)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
Also I added an application.properties file in resources folder:
spring.jpa.hibernate.ddl-auto=none
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.show_sql=false
spring.jpa.properties.hibernate.format_sql=false
And finally, I added a simple config file:
#Configuration
#ComponentScan
#EnableJpaRepositories("package-of-the-JPA-repositories")
//#EnableAutoConfiguration
#EntityScan("package-of-the-entities")
#PropertySource("classpath:/application.properties")
public class SpringConfig {
}
Well, this configuration done, I tried to run the main project, but it sais, it cannot find the entityManagerFactory bean. As I understood, Spring Boot should generate this bean from the specified properties. So my question would be: 1) Is the thing I am tring to do generally possible? Means, is it possible to use Spring Boot without having an #SpringBootApplication annotated class? Or should I rather get rid of Spring Boot and use only Spring Data and Hibernate? And if it is possible, what am I possibly doing wrong? Any ideas?
I have multi-module spring boot micro-service architecture like this:
<modules>
<module>commons</module>
<module>dao</module>
<module>service</module>
<module>api</module>
</modules>
Here I have put my Application.java in API module, which is having all the configuration. Now I want to test my service class methods but I am not able to add the configuration.
Do I need to write separate configuration or is there any other solution for this?
I deployed keycloak in tomcat with eclipse Luna based on this tutorial: https://reachmnadeem.wordpress.com/2015/01/14/deploying-keycloak-in-tomcat/#comment-245
I have it running in my machine and have no problem. Now I have to edit the login form based on my company design. But I do not have local files .css and .htmls to do it.
This is the parent project and some war configuration.
<parent>
<artifactId>keycloak-parent</artifactId>
<groupId>org.keycloak</groupId>
<version>1.1.0.Final</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>keycloak-war</artifactId>
<packaging>war</packaging>
<name>Keycloak Server</name>
<description />
Do I have to donwload the war project, the parent project? I do not know where to start.
First of all please be informed that it is recommended to use standalone Keycloak server - http://keycloak.github.io/docs/userguide/keycloak-server/html/server-installation.html)
And here some details how you are able to customize themes - http://docs.jboss.org/keycloak/docs/1.0-alpha-3/userguide/html/themes.html
You can unzip the keycloak-forms-common-themes-1.1.0.Beta2.jar and under login you can change the css and images and redeploy it
I have a multi-module maven 3 project, in which I have an orchestrator/build pom whose sole job is to run the maven build. Each module already has its parent pom, none of which are this orchestrator pom.
Is there any way from within the orchestrator pom to set/specify property values that would be used by the modules? Since the modules do not inherit the orchestrator pom, they know nothing of any property values set/specified within it (ex: ${buildEngine} or ${cluster}).
For ex:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sbic</groupId>
<artifactId>builder</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Orchestrator Pom</name>
<properties>
<buildEngine>Geronimo</buildEngine>
<cluster>peanuts</cluster>
</properties>
<modules>
<!-- Supert POM Component Versionning -->
<module>SbiComMavenCommon</module>
<!-- Projects -->
<module>../AlertServices</module>
<module>../Configuration</module>
<module>../Core</module>
</modules>
</project>
In order to build my project, I simply call mvn package on this builder pom.
What I am looking for is an ability to specify properties in this builder pom that would then be used by the modules, WITHOUT requiring the modules to have this pom in its parent tree.
For example, something that would accomplish the following (obviously not valid pom syntax):
<module>
../Core
<properties>
<name>SomeValue</name>
<server>192.168.1.2</server>
</properties>
</module>
There is no direct way to do it with Maven which I'm aware of. But, there is a workaround - use properties:set-system-properties from Properties Maven plugin
Of course, caveats apply, as for any global shared mutable state. For example, the module parent/child relationships are not respected. Though it looks like you want it anyway.
I am building a Spring MVC application and deploying to Tomcat. When I try to use the #Valid syntax, I get a compilation error:
Valid cannot be resolved to a type.
I am using Eclipse Java EE IDE for Web Developers (Helios SR2).
I have hibernate-validator.jar in my classpath, as the Spring documentation indicates, but I don't see javax.validation.* anywhere in my references.
Any help would be appreciated.
add
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
to your context and you have to have javax.validation.* classes on classpath
search for javax.validation in maven repositories or use following if you use Maven:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>com.springsource.javax.validation</artifactId>
<version>1.0.0.GA</version>
</dependency>