Uruchomienie projektu spring

0

Hej,

udało mi się postawić środowisko tomcat7, java8 i maven. Mam projekt który niestety jest pisany w innym języku (JAVA "SPRING" ) niż się znam ( PHP ). Próbuję odtworzyć sobie na localu ten projekt ( w skrócie jest to API ). Skopiowałem z gita repo uruchomiłem w folderze mvn clean install , maven zbudował mi target ( BUILD SUCCESS ) ale w przeglądarce w ogóle nie mogę dobierać się do adresów z API. W czym tkwi problem ? Co potrzebujecie wiedzieć ( co mam zamieścić tutaj) aby sprawdzić czy dobrze wszystko robię?

ps.Proszę o cierpliwość gdyż są to dla mnie nowe technologie.

Na początek 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>pl.bpo</groupId>
    <artifactId>archiwum</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <!--<packaging>pom</packaging>-->

    <name>archiwum</name>
    <description>Query layer for Archiwum</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <version>1.2.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>1.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>1.2.6.RELEASE</version>
            <scope>test</scope>
        </dependency>

        <!--Elasticsearch-->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-elasticsearch</artifactId>
            <version>1.3.0.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>1.2.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.33</version>
        </dependency>


        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-commons</artifactId>
            <version>1.11.0.RELEASE</version>
        </dependency>


        <!--Aerospike-->
        <dependency>
            <groupId>com.aerospike</groupId>
            <artifactId>aerospike-client</artifactId>
            <version>3.1.5</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.6</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-compress</artifactId>
            <version>1.0</version>
        </dependency>

    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.2.6.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

0

No musisz to jeszcze uruchomić np. przez jakieś java -jar co_tam_masz_w_target.jar (bo spring boot buduje ci chyba runnable war) albo mvn spring-boot:run

0

No właśnie i teraz otrzymuje błąd:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin
:1.2.6.RELEASE:run (default-cli) on project archiwum: An exception occure
d while running. null: InvocationTargetException: Error creating bean with name
'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration':
Injection of autowired dependencies failed; nested exception is org.springframew
ork.beans.factory.BeanCreationException: Could not autowire field: private javax
.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfigurat
ion.dataSource; nested exception is org.springframework.beans.factory.BeanCreati
onException: Error creating bean with name 'dataSource' defined in class path re
source [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$
NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; n
ested exception is org.springframework.beans.BeanInstantiationException: Failed
to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw excepti
on; nested exception is org.springframework.beans.factory.BeanCreationException:
 Cannot determine embedded database driver class for database type NONE. If you
want an embedded database please put a supported one on the classpath. -> [Help
1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception
0

A pokaż springowy kontekst i konfiguracje datasource bo log mówi że baza nie jest w projekcie skonfigurowana.

0

Ok pokażę tylko jakbyś mnie naprowadził w którym miejscu to powinno się znajdywać.

0

Albo będą tam pliki xml w stylu application-context.xml albo dispatcher-servlet.xml albo będzie w projekcie klasa z różnymi adnotacjami typu @Configuration i @Bean ;]
Prościej będzie jak poszukać w projekcie stringa dataSource ;]

0

Z tego co widzę to znajduje 3 pliki konfiguracyjne Aerospike, Elasticsearch i Rawfiles.
Dla stringa dataSource znajduje dwa pliki dev i prod a w nich np:

spring.data.elasticsearch.cluster-nodes=xxxx:9300
#  if spring data repository support is enabled
spring.data.elasticsearch.repositories.enabled=true
spring.data.elasticsearch.clusterName=xxx

spring.data.elasticsearch.properties.http.enabled=true
spring.data.elasticsearch.cluster-name=xxx
spring.data.elasticsearch.properties.node.local=false
spring.data.elasticsearch.properties.node.data=false
spring.data.elasticsearch.properties.node.client=true

elasticsearch.host=xxxx
elasticsearch.port=9300
elasticsearch.clusterName=xxx

aerospike.host=xxxx
aerospike.port=3000
server.port = 9876

server.tomcat.accessLogEnabled=true
server.tomcat.accessLogPattern=%h %l %u %t "%r" %s %b %D
server.tomcat.basedir=/tmp/logs

spring.datasource.url=jdbc:mysql://localhost/xxx
spring.datasource.username=root
spring.datasource.password=xxxx
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

rawfiles.path=/tmp/raw
rawfiles.prefix=xxx
rawfiles.sufix=.raw

0

Wychodzi na to że coś jest nie tak z Bazą danych. Ok rozumiem tylko jak mam to rozwiązać?

Puściłem na serwie:
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install libmysql-java

Ale błąd pozostaje ten sam.

0

https://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html
Błąd polega na tym że uzywasz Spring-Boot ale chcesz zrobic coś "niestandardowego". Defaultowo boot korzysta z jakieś bazy embedded (np. h2) i szuka sobie drivera dla takiej bazy. Jeśli chcesz użyć innej to musisz to odpowiednio skonfigurować.

0

tak, bedzie sie laczyl, ale wygląda na to, że ten agent nie stworzyl jeszcze zadnej bazy. Jak to gotowy projekt to zapusc jakas migracje, a moze masz gdzies dump tej bazy? Jak dopiero co 'zapusciles na serwie' instalację mysqla no to musisz jeszcze utworzyć usera, bazkę itd...

1 użytkowników online, w tym zalogowanych: 0, gości: 1